| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| 6 #define WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
| 10 #include "webkit/appcache/appcache_entry.h" | 10 #include "webkit/appcache/appcache_entry.h" |
| 11 #include "webkit/appcache/appcache_export.h" | 11 #include "webkit/appcache/appcache_export.h" |
| 12 #include "webkit/appcache/appcache_host.h" | 12 #include "webkit/appcache/appcache_host.h" |
| 13 #include "webkit/glue/resource_type.h" | 13 #include "webkit/glue/resource_type.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 class NetworkDelegate; |
| 16 class URLRequest; | 17 class URLRequest; |
| 17 class URLRequestJob; | 18 class URLRequestJob; |
| 18 } // namespace net | 19 } // namespace net |
| 19 | 20 |
| 20 namespace appcache { | 21 namespace appcache { |
| 21 | 22 |
| 22 class AppCacheURLRequestJob; | 23 class AppCacheURLRequestJob; |
| 23 | 24 |
| 24 // An instance is created for each net::URLRequest. The instance survives all | 25 // An instance is created for each net::URLRequest. The instance survives all |
| 25 // http transactions involved in the processing of its net::URLRequest, and is | 26 // http transactions involved in the processing of its net::URLRequest, and is |
| 26 // given the opportunity to hijack the request along the way. Callers | 27 // given the opportunity to hijack the request along the way. Callers |
| 27 // should use AppCacheHost::CreateRequestHandler to manufacture instances | 28 // should use AppCacheHost::CreateRequestHandler to manufacture instances |
| 28 // that can retrieve resources for a particular host. | 29 // that can retrieve resources for a particular host. |
| 29 class APPCACHE_EXPORT AppCacheRequestHandler | 30 class APPCACHE_EXPORT AppCacheRequestHandler |
| 30 : public base::SupportsUserData::Data, | 31 : public base::SupportsUserData::Data, |
| 31 public AppCacheHost::Observer, | 32 public AppCacheHost::Observer, |
| 32 public AppCacheStorage::Delegate { | 33 public AppCacheStorage::Delegate { |
| 33 public: | 34 public: |
| 34 virtual ~AppCacheRequestHandler(); | 35 virtual ~AppCacheRequestHandler(); |
| 35 | 36 |
| 36 // These are called on each request intercept opportunity. | 37 // These are called on each request intercept opportunity. |
| 37 AppCacheURLRequestJob* MaybeLoadResource(net::URLRequest* request); | 38 AppCacheURLRequestJob* MaybeLoadResource( |
| 38 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect(net::URLRequest* request, | 39 net::URLRequest* request, net::NetworkDelegate* network_delegate); |
| 39 const GURL& location); | 40 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect( |
| 40 AppCacheURLRequestJob* MaybeLoadFallbackForResponse(net::URLRequest* request); | 41 net::URLRequest* request, |
| 42 net::NetworkDelegate* network_delegate, |
| 43 const GURL& location); |
| 44 AppCacheURLRequestJob* MaybeLoadFallbackForResponse( |
| 45 net::URLRequest* request, net::NetworkDelegate* network_delegate); |
| 41 | 46 |
| 42 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); | 47 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); |
| 43 | 48 |
| 44 static bool IsMainResourceType(ResourceType::Type type) { | 49 static bool IsMainResourceType(ResourceType::Type type) { |
| 45 return ResourceType::IsFrame(type) || | 50 return ResourceType::IsFrame(type) || |
| 46 ResourceType::IsSharedWorker(type); | 51 ResourceType::IsSharedWorker(type); |
| 47 } | 52 } |
| 48 | 53 |
| 49 private: | 54 private: |
| 50 friend class AppCacheHost; | 55 friend class AppCacheHost; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 // Helper to retrieve a pointer to the storage object. | 72 // Helper to retrieve a pointer to the storage object. |
| 68 AppCacheStorage* storage() const; | 73 AppCacheStorage* storage() const; |
| 69 | 74 |
| 70 bool is_main_resource() const { | 75 bool is_main_resource() const { |
| 71 return IsMainResourceType(resource_type_); | 76 return IsMainResourceType(resource_type_); |
| 72 } | 77 } |
| 73 | 78 |
| 74 // Main-resource loading ------------------------------------- | 79 // Main-resource loading ------------------------------------- |
| 75 // Frame and SharedWorker main resources are handled here. | 80 // Frame and SharedWorker main resources are handled here. |
| 76 | 81 |
| 77 void MaybeLoadMainResource(net::URLRequest* request); | 82 void MaybeLoadMainResource(net::URLRequest* request, |
| 83 net::NetworkDelegate* network_delegate); |
| 78 | 84 |
| 79 // AppCacheStorage::Delegate methods | 85 // AppCacheStorage::Delegate methods |
| 80 virtual void OnMainResponseFound( | 86 virtual void OnMainResponseFound( |
| 81 const GURL& url, const AppCacheEntry& entry, | 87 const GURL& url, const AppCacheEntry& entry, |
| 82 const GURL& fallback_url, const AppCacheEntry& fallback_entry, | 88 const GURL& fallback_url, const AppCacheEntry& fallback_entry, |
| 83 int64 cache_id, int64 group_id, const GURL& mainfest_url) OVERRIDE; | 89 int64 cache_id, int64 group_id, const GURL& mainfest_url) OVERRIDE; |
| 84 | 90 |
| 85 // Sub-resource loading ------------------------------------- | 91 // Sub-resource loading ------------------------------------- |
| 86 // Dedicated worker and all manner of sub-resources are handled here. | 92 // Dedicated worker and all manner of sub-resources are handled here. |
| 87 | 93 |
| 88 void MaybeLoadSubResource(net::URLRequest* request); | 94 void MaybeLoadSubResource(net::URLRequest* request, |
| 95 net::NetworkDelegate* network_delegate); |
| 89 void ContinueMaybeLoadSubResource(); | 96 void ContinueMaybeLoadSubResource(); |
| 90 | 97 |
| 91 // AppCacheHost::Observer override | 98 // AppCacheHost::Observer override |
| 92 virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE; | 99 virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE; |
| 93 | 100 |
| 94 // Data members ----------------------------------------------- | 101 // Data members ----------------------------------------------- |
| 95 | 102 |
| 96 // What host we're servicing a request for. | 103 // What host we're servicing a request for. |
| 97 AppCacheHost* host_; | 104 AppCacheHost* host_; |
| 98 | 105 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 121 // The job we use to deliver a response. | 128 // The job we use to deliver a response. |
| 122 scoped_refptr<AppCacheURLRequestJob> job_; | 129 scoped_refptr<AppCacheURLRequestJob> job_; |
| 123 | 130 |
| 124 friend class AppCacheRequestHandlerTest; | 131 friend class AppCacheRequestHandlerTest; |
| 125 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); | 132 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
| 126 }; | 133 }; |
| 127 | 134 |
| 128 } // namespace appcache | 135 } // namespace appcache |
| 129 | 136 |
| 130 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 137 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| OLD | NEW |