diff options
Diffstat (limited to 'chrome_frame/urlmon_url_request_private.h')
-rw-r--r-- | chrome_frame/urlmon_url_request_private.h | 66 |
1 files changed, 13 insertions, 53 deletions
diff --git a/chrome_frame/urlmon_url_request_private.h b/chrome_frame/urlmon_url_request_private.h index f8c3561..f116998 100644 --- a/chrome_frame/urlmon_url_request_private.h +++ b/chrome_frame/urlmon_url_request_private.h @@ -8,7 +8,6 @@ #include <atlbase.h> #include <atlcom.h> #include <string> -#include <deque> #include "net/base/net_errors.h" #include "net/http/http_response_headers.h" @@ -52,9 +51,9 @@ class UrlmonUrlRequest privileged_mode_ = privileged_mode; } - bool IsForUrl(const GURL& other) const { - return url_ == other; - } + // Returns a string in the form " id: %i Obj: %X URL: %s" which is useful + // to identify request objects in the log. + std::string me() const; protected: UrlmonUrlRequest(); @@ -73,25 +72,24 @@ class UrlmonUrlRequest SERVICE_ENTRY(IID_IHttpNegotiate); END_SERVICE_MAP() - // IBindStatusCallback implementation STDMETHOD(OnStartBinding)(DWORD reserved, IBinding* binding); STDMETHOD(GetPriority)(LONG* priority); STDMETHOD(OnLowResource)(DWORD reserved); STDMETHOD(OnProgress)(ULONG progress, ULONG max_progress, - ULONG status_code, LPCWSTR status_text); + ULONG status_code, LPCWSTR status_text); STDMETHOD(OnStopBinding)(HRESULT result, LPCWSTR error); STDMETHOD(GetBindInfo)(DWORD* bind_flags, BINDINFO* bind_info); STDMETHOD(OnDataAvailable)(DWORD flags, DWORD size, FORMATETC* formatetc, - STGMEDIUM* storage); + STGMEDIUM* storage); STDMETHOD(OnObjectAvailable)(REFIID iid, IUnknown* object); // IHttpNegotiate implementation STDMETHOD(BeginningTransaction)(const wchar_t* url, - const wchar_t* current_headers, DWORD reserved, - wchar_t** additional_headers); + const wchar_t* current_headers, DWORD reserved, + wchar_t** additional_headers); STDMETHOD(OnResponse)(DWORD dwResponseCode, const wchar_t* response_headers, - const wchar_t* request_headers, wchar_t** additional_headers); + const wchar_t* request_headers, wchar_t** additional_headers); // IWindowForBindingUI implementation. This interface is used typically to // query the window handle which URLMON uses as the parent of error dialogs. @@ -100,7 +98,7 @@ class UrlmonUrlRequest // IAuthenticate implementation. Used to return the parent window for the // dialog displayed by IE for authenticating with a proxy. STDMETHOD(Authenticate)(HWND* parent_window, LPWSTR* user_name, - LPWSTR* password); + LPWSTR* password); // IHttpSecurity implementation. STDMETHOD(OnSecurityProblem)(DWORD problem); @@ -124,52 +122,13 @@ class UrlmonUrlRequest protected: void ReleaseBindings(); - // Manage data caching. Note: this class supports cache - // size less than 2GB - FRIEND_TEST(UrlmonUrlRequestCache, ReadWrite); - class Cache { - public: - Cache() : size_(0), read_offset_(0), write_offset_(0) { - } - - ~Cache(); - - // Adds data to the end of the cache. - bool Append(IStream* source); - // Copies up to |bytes| bytes from the cache to |dest| buffer. - bool Read(void* dest, size_t bytes, size_t* bytes_copied); - - // Returns the size of the cache. - size_t size() const { - return size_; - } - - // Returns true if the cache has valid data. - bool is_valid() const { - return size() != 0; - } - - private: - FRIEND_TEST(UrlmonUrlRequestCache, ReadWrite); - void GetWriteBuffer(void** dest, size_t* bytes_avail); - void BytesWritten(size_t bytes); - void GetReadBuffer(void** src, size_t* bytes_avail); - void BytesRead(size_t bytes); - - static const size_t BUF_SIZE = 0x8000; // 32k - std::deque<uint8*> cache_; - size_t size_; - size_t read_offset_; - size_t write_offset_; - std::deque<uint8*> pool_; - }; - HRESULT StartAsyncDownload(); void NotifyDelegateAndDie(); static net::Error HresultToNetError(HRESULT hr); private: size_t SendDataToDelegate(size_t bytes); + // This class simplifies tracking the progress of operation. We have 3 main // states: DONE, WORKING and ABORTING. // When in [DONE] or [ABORTING] state, there is additional information @@ -268,8 +227,9 @@ class UrlmonUrlRequest ScopedComPtr<IBinding> binding_; ScopedComPtr<IMoniker> moniker_; ScopedComPtr<IBindCtx> bind_context_; - GURL url_; - Cache cached_data_; + ScopedComPtr<IStream> cache_; + ScopedComPtr<IStream> pending_data_; + size_t pending_read_size_; PlatformThreadId thread_; HWND parent_window_; |