2 * Copyright 2010-2014 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _B_URL_REQUEST_H_
6 #define _B_URL_REQUEST_H_
10 #include <UrlContext.h>
11 #include <UrlProtocolListener.h>
12 #include <UrlResult.h>
14 #include <Referenceable.h>
19 BUrlRequest(const BUrl
& url
,
20 BUrlProtocolListener
* listener
,
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;
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
, ...);
58 BReference
<BUrlContext
> fContext
;
59 BUrlProtocolListener
* fListener
;
63 status_t fThreadStatus
;
70 #endif // _B_URL_REQUEST_H_