1 /* 2 * Copyright 2010 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _B_URL_SYNCHRONOUS_REQUEST_H_ 6 #define _B_URL_SYNCHRONOUS_REQUEST_H_ 7 8 9 #include <UrlRequest.h> 10 #include <UrlProtocolListener.h> 11 12 13 namespace BPrivate { 14 15 namespace Network { 16 17 18 class BUrlSynchronousRequest : public BUrlRequest, public BUrlProtocolListener { 19 public: 20 BUrlSynchronousRequest(BUrlRequest& asynchronousRequest); 21 virtual ~BUrlSynchronousRequest() { }; 22 23 // Synchronous wait 24 virtual status_t Perform(); 25 virtual status_t WaitUntilCompletion(); 26 27 // Protocol hooks 28 virtual void ConnectionOpened(BUrlRequest* caller); 29 virtual void HostnameResolved(BUrlRequest* caller, 30 const char* ip); 31 virtual void ResponseStarted(BUrlRequest* caller); 32 virtual void HeadersReceived(BUrlRequest* caller); 33 virtual void BytesWritten(BUrlRequest* caller, 34 size_t bytesWritten); 35 virtual void DownloadProgress(BUrlRequest* caller, 36 off_t bytesReceived, off_t bytesTotal); 37 virtual void UploadProgress(BUrlRequest* caller, 38 off_t bytesSent, off_t bytesTotal); 39 40 virtual void RequestCompleted(BUrlRequest* caller, 41 bool success); 42 43 protected: 44 bool fRequestComplete; 45 BUrlRequest& fWrappedRequest; 46 }; 47 48 49 } // namespace Network 50 51 } // namespace BPrivate 52 53 #endif // _B_URL_SYNCHRONOUS_REQUEST_H_ 54