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 CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 6 #define CONTENT_BROWSER_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 "content/browser/appcache/appcache_entry.h" | 10 #include "content/browser/appcache/appcache_entry.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // 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 |
26 // 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 |
27 // given the opportunity to hijack the request along the way. Callers | 27 // given the opportunity to hijack the request along the way. Callers |
28 // should use AppCacheHost::CreateRequestHandler to manufacture instances | 28 // should use AppCacheHost::CreateRequestHandler to manufacture instances |
29 // that can retrieve resources for a particular host. | 29 // that can retrieve resources for a particular host. |
30 class CONTENT_EXPORT AppCacheRequestHandler | 30 class CONTENT_EXPORT AppCacheRequestHandler |
31 : public base::SupportsUserData::Data, | 31 : public base::SupportsUserData::Data, |
32 public AppCacheHost::Observer, | 32 public AppCacheHost::Observer, |
33 public AppCacheStorage::Delegate { | 33 public AppCacheStorage::Delegate { |
34 public: | 34 public: |
35 virtual ~AppCacheRequestHandler(); | 35 ~AppCacheRequestHandler() override; |
36 | 36 |
37 // These are called on each request intercept opportunity. | 37 // These are called on each request intercept opportunity. |
38 AppCacheURLRequestJob* MaybeLoadResource( | 38 AppCacheURLRequestJob* MaybeLoadResource( |
39 net::URLRequest* request, net::NetworkDelegate* network_delegate); | 39 net::URLRequest* request, net::NetworkDelegate* network_delegate); |
40 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect( | 40 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect( |
41 net::URLRequest* request, | 41 net::URLRequest* request, |
42 net::NetworkDelegate* network_delegate, | 42 net::NetworkDelegate* network_delegate, |
43 const GURL& location); | 43 const GURL& location); |
44 AppCacheURLRequestJob* MaybeLoadFallbackForResponse( | 44 AppCacheURLRequestJob* MaybeLoadFallbackForResponse( |
45 net::URLRequest* request, net::NetworkDelegate* network_delegate); | 45 net::URLRequest* request, net::NetworkDelegate* network_delegate); |
46 | 46 |
47 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); | 47 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); |
48 | 48 |
49 // Methods to support cross site navigations. | 49 // Methods to support cross site navigations. |
50 void PrepareForCrossSiteTransfer(int old_process_id); | 50 void PrepareForCrossSiteTransfer(int old_process_id); |
51 void CompleteCrossSiteTransfer(int new_process_id, int new_host_id); | 51 void CompleteCrossSiteTransfer(int new_process_id, int new_host_id); |
52 | 52 |
53 static bool IsMainResourceType(ResourceType type) { | 53 static bool IsMainResourceType(ResourceType type) { |
54 return IsResourceTypeFrame(type) || | 54 return IsResourceTypeFrame(type) || |
55 type == RESOURCE_TYPE_SHARED_WORKER; | 55 type == RESOURCE_TYPE_SHARED_WORKER; |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 friend class AppCacheHost; | 59 friend class AppCacheHost; |
60 | 60 |
61 // Callers should use AppCacheHost::CreateRequestHandler. | 61 // Callers should use AppCacheHost::CreateRequestHandler. |
62 AppCacheRequestHandler(AppCacheHost* host, ResourceType resource_type); | 62 AppCacheRequestHandler(AppCacheHost* host, ResourceType resource_type); |
63 | 63 |
64 // AppCacheHost::Observer override | 64 // AppCacheHost::Observer override |
65 virtual void OnDestructionImminent(AppCacheHost* host) override; | 65 void OnDestructionImminent(AppCacheHost* host) override; |
66 | 66 |
67 // Helpers to instruct a waiting job with what response to | 67 // Helpers to instruct a waiting job with what response to |
68 // deliver for the request we're handling. | 68 // deliver for the request we're handling. |
69 void DeliverAppCachedResponse(const AppCacheEntry& entry, int64 cache_id, | 69 void DeliverAppCachedResponse(const AppCacheEntry& entry, int64 cache_id, |
70 int64 group_id, const GURL& manifest_url, | 70 int64 group_id, const GURL& manifest_url, |
71 bool is_fallback, | 71 bool is_fallback, |
72 const GURL& namespace_entry_url); | 72 const GURL& namespace_entry_url); |
73 void DeliverNetworkResponse(); | 73 void DeliverNetworkResponse(); |
74 void DeliverErrorResponse(); | 74 void DeliverErrorResponse(); |
75 | 75 |
76 // Helper to retrieve a pointer to the storage object. | 76 // Helper to retrieve a pointer to the storage object. |
77 AppCacheStorage* storage() const; | 77 AppCacheStorage* storage() const; |
78 | 78 |
79 bool is_main_resource() const { | 79 bool is_main_resource() const { |
80 return IsMainResourceType(resource_type_); | 80 return IsMainResourceType(resource_type_); |
81 } | 81 } |
82 | 82 |
83 // Main-resource loading ------------------------------------- | 83 // Main-resource loading ------------------------------------- |
84 // Frame and SharedWorker main resources are handled here. | 84 // Frame and SharedWorker main resources are handled here. |
85 | 85 |
86 void MaybeLoadMainResource(net::URLRequest* request, | 86 void MaybeLoadMainResource(net::URLRequest* request, |
87 net::NetworkDelegate* network_delegate); | 87 net::NetworkDelegate* network_delegate); |
88 | 88 |
89 // AppCacheStorage::Delegate methods | 89 // AppCacheStorage::Delegate methods |
90 virtual void OnMainResponseFound( | 90 void OnMainResponseFound(const GURL& url, |
91 const GURL& url, const AppCacheEntry& entry, | 91 const AppCacheEntry& entry, |
92 const GURL& fallback_url, const AppCacheEntry& fallback_entry, | 92 const GURL& fallback_url, |
93 int64 cache_id, int64 group_id, const GURL& mainfest_url) override; | 93 const AppCacheEntry& fallback_entry, |
| 94 int64 cache_id, |
| 95 int64 group_id, |
| 96 const GURL& mainfest_url) override; |
94 | 97 |
95 // Sub-resource loading ------------------------------------- | 98 // Sub-resource loading ------------------------------------- |
96 // Dedicated worker and all manner of sub-resources are handled here. | 99 // Dedicated worker and all manner of sub-resources are handled here. |
97 | 100 |
98 void MaybeLoadSubResource(net::URLRequest* request, | 101 void MaybeLoadSubResource(net::URLRequest* request, |
99 net::NetworkDelegate* network_delegate); | 102 net::NetworkDelegate* network_delegate); |
100 void ContinueMaybeLoadSubResource(); | 103 void ContinueMaybeLoadSubResource(); |
101 | 104 |
102 // AppCacheHost::Observer override | 105 // AppCacheHost::Observer override |
103 virtual void OnCacheSelectionComplete(AppCacheHost* host) override; | 106 void OnCacheSelectionComplete(AppCacheHost* host) override; |
104 | 107 |
105 // Data members ----------------------------------------------- | 108 // Data members ----------------------------------------------- |
106 | 109 |
107 // What host we're servicing a request for. | 110 // What host we're servicing a request for. |
108 AppCacheHost* host_; | 111 AppCacheHost* host_; |
109 | 112 |
110 // Frame vs subresource vs sharedworker loads are somewhat different. | 113 // Frame vs subresource vs sharedworker loads are somewhat different. |
111 ResourceType resource_type_; | 114 ResourceType resource_type_; |
112 | 115 |
113 // Subresource requests wait until after cache selection completes. | 116 // Subresource requests wait until after cache selection completes. |
(...skipping 25 matching lines...) Expand all Loading... |
139 // from the old processes structures over to the new structures. | 142 // from the old processes structures over to the new structures. |
140 scoped_ptr<AppCacheHost> host_for_cross_site_transfer_; | 143 scoped_ptr<AppCacheHost> host_for_cross_site_transfer_; |
141 | 144 |
142 friend class content::AppCacheRequestHandlerTest; | 145 friend class content::AppCacheRequestHandlerTest; |
143 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); | 146 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
144 }; | 147 }; |
145 | 148 |
146 } // namespace content | 149 } // namespace content |
147 | 150 |
148 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 151 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
OLD | NEW |