diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 00:09:21 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 00:09:21 +0000 |
commit | 3367fc1dd134eeaf9ab6e62397f05ad3964319fe (patch) | |
tree | 78fb4d7ac912bbaf47b64f0aaefef331906b5fca /webkit/appcache/appcache_request_handler.h | |
parent | 9f9e1fcbbd52267fa657b3b0b80ece683ceb6dd6 (diff) | |
download | chromium_src-3367fc1dd134eeaf9ab6e62397f05ad3964319fe.zip chromium_src-3367fc1dd134eeaf9ab6e62397f05ad3964319fe.tar.gz chromium_src-3367fc1dd134eeaf9ab6e62397f05ad3964319fe.tar.bz2 |
AppCache changes to the networking model. Added new classes AppCacheRequestHandler and AppCacheURLRequestJob.
TEST=appcache_url_request_job_unittest.cc, appcache_request_handler_unittest.cc
BUG=none
Review URL: http://codereview.chromium.org/338034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31411 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_request_handler.h')
-rw-r--r-- | webkit/appcache/appcache_request_handler.h | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/webkit/appcache/appcache_request_handler.h b/webkit/appcache/appcache_request_handler.h index d848f08..55b4ef7 100644 --- a/webkit/appcache/appcache_request_handler.h +++ b/webkit/appcache/appcache_request_handler.h @@ -13,21 +13,24 @@ class URLRequestJob; namespace appcache { +class AppCacheURLRequestJob; + // An instance is created for each URLRequest. The instance survives all // http transactions involved in the processing of its URLRequest, and is // given the opportunity to hijack the request along the way. Callers // should use AppCacheHost::CreateRequestHandler to manufacture instances // that can retrieve resources for a particular host. class AppCacheRequestHandler : public URLRequest::UserData, - public AppCacheHost::Observer { + public AppCacheHost::Observer, + public AppCacheStorage::Delegate { public: virtual ~AppCacheRequestHandler(); - // Should be called on each request intercept opportunity. - URLRequestJob* MaybeLoadResource(URLRequest* request); - URLRequestJob* MaybeLoadFallbackForRedirect(URLRequest* request, - const GURL& location); - URLRequestJob* MaybeLoadFallbackForResponse(URLRequest* request); + // These are called on each request intercept opportunity. + AppCacheURLRequestJob* MaybeLoadResource(URLRequest* request); + AppCacheURLRequestJob* MaybeLoadFallbackForRedirect(URLRequest* request, + const GURL& location); + AppCacheURLRequestJob* MaybeLoadFallbackForResponse(URLRequest* request); void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); @@ -37,16 +40,61 @@ class AppCacheRequestHandler : public URLRequest::UserData, // Callers should use AppCacheHost::CreateRequestHandler. AppCacheRequestHandler(AppCacheHost* host, bool is_main_resource); - // AppCacheHost::Observer methods - virtual void OnCacheSelectionComplete(AppCacheHost* host); + // AppCacheHost::Observer override virtual void OnDestructionImminent(AppCacheHost* host); - // Main vs subresource loads are very different. - // TODO(michaeln): maybe have two derived classes? - bool is_main_request_; + // Helpers to instruct a waiting job with what response to + // deliver for the request we're handling. + void DeliverAppCachedResponse(const AppCacheEntry& entry, int64 cache_id, + const GURL& manifest_url); + void DeliverNetworkResponse(); + void DeliverErrorResponse(); + + // Helper to retrieve a pointer to the storage object. + AppCacheStorage* storage(); + + // Main-resource loading ------------------------------------- + + void MaybeLoadMainResource(URLRequest* request); + + // AppCacheStorage::Delegate methods + virtual void OnMainResponseFound( + const GURL& url, const AppCacheEntry& entry, + const AppCacheEntry& fallback_entry, + int64 cache_id, const GURL& mainfest_url); + + // Sub-resource loading ------------------------------------- + + void MaybeLoadSubResource(URLRequest* request); + void ContinueMaybeLoadSubResource(); + + // AppCacheHost::Observer override + virtual void OnCacheSelectionComplete(AppCacheHost* host); + + // Data members ----------------------------------------------- + + // What host we're servicing a request for. AppCacheHost* host_; - scoped_refptr<AppCache> cache_; - scoped_refptr<URLRequestJob> job_; + + // Main vs subresource loads are somewhat different. + bool is_main_request_; + + // Subresource requests wait until after cache selection completes. + bool is_waiting_for_cache_selection_; + + // Info about the type of response we found for delivery. + // These are relevant for both main and subresource requests. + AppCacheEntry found_entry_; + AppCacheEntry found_fallback_entry_; + int64 found_cache_id_; + GURL found_manifest_url_; + bool found_network_namespace_; + + // The job we use to deliver a response. + scoped_refptr<AppCacheURLRequestJob> job_; + + friend class AppCacheRequestHandlerTest; + DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); }; } // namespace appcache |