Fix FreeBSD build.
[haiku.git] / headers / os / net / UrlRequest.h
blob1a323fae81152368b20cd8aef5803cb4506e3dbc
1 /*
2 * Copyright 2010-2014 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _B_URL_REQUEST_H_
6 #define _B_URL_REQUEST_H_
9 #include <Url.h>
10 #include <UrlContext.h>
11 #include <UrlProtocolListener.h>
12 #include <UrlResult.h>
13 #include <OS.h>
14 #include <Referenceable.h>
17 class BUrlRequest {
18 public:
19 BUrlRequest(const BUrl& url,
20 BUrlProtocolListener* listener,
21 BUrlContext* context,
22 const char* threadName,
23 const char* protocolName);
24 virtual ~BUrlRequest();
26 // URL protocol thread management
27 virtual thread_id Run();
28 virtual status_t Pause();
29 virtual status_t Resume();
30 virtual status_t Stop();
31 virtual void SetTimeout(bigtime_t timeout) {}
33 // URL protocol parameters modification
34 status_t SetUrl(const BUrl& url);
35 status_t SetContext(BUrlContext* context);
36 status_t SetListener(BUrlProtocolListener* listener);
38 // URL protocol parameters access
39 const BUrl& Url() const;
40 BUrlContext* Context() const;
41 BUrlProtocolListener* Listener() const;
42 const BString& Protocol() const;
44 // URL protocol informations
45 bool IsRunning() const;
46 status_t Status() const;
47 virtual const BUrlResult& Result() const = 0;
50 protected:
51 static int32 _ThreadEntry(void* arg);
52 virtual void _ProtocolSetup() {};
53 virtual status_t _ProtocolLoop() = 0;
54 virtual void _EmitDebug(BUrlProtocolDebugMessage type,
55 const char* format, ...);
56 protected:
57 BUrl fUrl;
58 BReference<BUrlContext> fContext;
59 BUrlProtocolListener* fListener;
61 bool fQuit;
62 bool fRunning;
63 status_t fThreadStatus;
64 thread_id fThreadId;
65 BString fThreadName;
66 BString fProtocol;
70 #endif // _B_URL_REQUEST_H_