| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
| 15 #include "content/browser/appcache/appcache_entry.h" | 16 #include "content/browser/appcache/appcache_entry.h" |
| 16 #include "content/browser/appcache/appcache_host.h" | 17 #include "content/browser/appcache/appcache_host.h" |
| 17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 18 #include "content/public/common/resource_type.h" | 19 #include "content/public/common/resource_type.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class NetworkDelegate; | 22 class NetworkDelegate; |
| 22 class URLRequest; | 23 class URLRequest; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 const GURL& namespace_entry_url); | 91 const GURL& namespace_entry_url); |
| 91 void DeliverNetworkResponse(); | 92 void DeliverNetworkResponse(); |
| 92 void DeliverErrorResponse(); | 93 void DeliverErrorResponse(); |
| 93 | 94 |
| 94 // Called just before the request is restarted. Grabs the reason for | 95 // Called just before the request is restarted. Grabs the reason for |
| 95 // restarting, so can correctly continue to handle the request. | 96 // restarting, so can correctly continue to handle the request. |
| 96 void OnPrepareToRestart(); | 97 void OnPrepareToRestart(); |
| 97 | 98 |
| 98 // Helper method to create an AppCacheURLRequestJob and populate job_. | 99 // Helper method to create an AppCacheURLRequestJob and populate job_. |
| 99 // Caller takes ownership of returned value. | 100 // Caller takes ownership of returned value. |
| 100 scoped_ptr<AppCacheURLRequestJob> CreateJob( | 101 std::unique_ptr<AppCacheURLRequestJob> CreateJob( |
| 101 net::URLRequest* request, | 102 net::URLRequest* request, |
| 102 net::NetworkDelegate* network_delegate); | 103 net::NetworkDelegate* network_delegate); |
| 103 | 104 |
| 104 // Helper to retrieve a pointer to the storage object. | 105 // Helper to retrieve a pointer to the storage object. |
| 105 AppCacheStorage* storage() const; | 106 AppCacheStorage* storage() const; |
| 106 | 107 |
| 107 bool is_main_resource() const { | 108 bool is_main_resource() const { |
| 108 return IsMainResourceType(resource_type_); | 109 return IsMainResourceType(resource_type_); |
| 109 } | 110 } |
| 110 | 111 |
| 111 // Main-resource loading ------------------------------------- | 112 // Main-resource loading ------------------------------------- |
| 112 // Frame and SharedWorker main resources are handled here. | 113 // Frame and SharedWorker main resources are handled here. |
| 113 | 114 |
| 114 scoped_ptr<AppCacheURLRequestJob> MaybeLoadMainResource( | 115 std::unique_ptr<AppCacheURLRequestJob> MaybeLoadMainResource( |
| 115 net::URLRequest* request, | 116 net::URLRequest* request, |
| 116 net::NetworkDelegate* network_delegate); | 117 net::NetworkDelegate* network_delegate); |
| 117 | 118 |
| 118 // AppCacheStorage::Delegate methods | 119 // AppCacheStorage::Delegate methods |
| 119 void OnMainResponseFound(const GURL& url, | 120 void OnMainResponseFound(const GURL& url, |
| 120 const AppCacheEntry& entry, | 121 const AppCacheEntry& entry, |
| 121 const GURL& fallback_url, | 122 const GURL& fallback_url, |
| 122 const AppCacheEntry& fallback_entry, | 123 const AppCacheEntry& fallback_entry, |
| 123 int64_t cache_id, | 124 int64_t cache_id, |
| 124 int64_t group_id, | 125 int64_t group_id, |
| 125 const GURL& mainfest_url) override; | 126 const GURL& mainfest_url) override; |
| 126 | 127 |
| 127 // Sub-resource loading ------------------------------------- | 128 // Sub-resource loading ------------------------------------- |
| 128 // Dedicated worker and all manner of sub-resources are handled here. | 129 // Dedicated worker and all manner of sub-resources are handled here. |
| 129 | 130 |
| 130 scoped_ptr<AppCacheURLRequestJob> MaybeLoadSubResource( | 131 std::unique_ptr<AppCacheURLRequestJob> MaybeLoadSubResource( |
| 131 net::URLRequest* request, | 132 net::URLRequest* request, |
| 132 net::NetworkDelegate* network_delegate); | 133 net::NetworkDelegate* network_delegate); |
| 133 void ContinueMaybeLoadSubResource(); | 134 void ContinueMaybeLoadSubResource(); |
| 134 | 135 |
| 135 // AppCacheHost::Observer override | 136 // AppCacheHost::Observer override |
| 136 void OnCacheSelectionComplete(AppCacheHost* host) override; | 137 void OnCacheSelectionComplete(AppCacheHost* host) override; |
| 137 | 138 |
| 138 // Data members ----------------------------------------------- | 139 // Data members ----------------------------------------------- |
| 139 | 140 |
| 140 // What host we're servicing a request for. | 141 // What host we're servicing a request for. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 bool maybe_load_resource_executed_; | 175 bool maybe_load_resource_executed_; |
| 175 | 176 |
| 176 // The job we use to deliver a response. Only NULL during the following times: | 177 // The job we use to deliver a response. Only NULL during the following times: |
| 177 // 1) Before request has started a job. | 178 // 1) Before request has started a job. |
| 178 // 2) Request is not being handled by appcache. | 179 // 2) Request is not being handled by appcache. |
| 179 // 3) Request has been cancelled, and the job killed. | 180 // 3) Request has been cancelled, and the job killed. |
| 180 base::WeakPtr<AppCacheURLRequestJob> job_; | 181 base::WeakPtr<AppCacheURLRequestJob> job_; |
| 181 | 182 |
| 182 // During a cross site navigation, we transfer ownership the AppcacheHost | 183 // During a cross site navigation, we transfer ownership the AppcacheHost |
| 183 // from the old processes structures over to the new structures. | 184 // from the old processes structures over to the new structures. |
| 184 scoped_ptr<AppCacheHost> host_for_cross_site_transfer_; | 185 std::unique_ptr<AppCacheHost> host_for_cross_site_transfer_; |
| 185 int old_process_id_; | 186 int old_process_id_; |
| 186 int old_host_id_; | 187 int old_host_id_; |
| 187 | 188 |
| 188 // Cached information about the response being currently served by the | 189 // Cached information about the response being currently served by the |
| 189 // AppCache, if there is one. | 190 // AppCache, if there is one. |
| 190 int cache_id_; | 191 int cache_id_; |
| 191 GURL manifest_url_; | 192 GURL manifest_url_; |
| 192 | 193 |
| 193 friend class content::AppCacheRequestHandlerTest; | 194 friend class content::AppCacheRequestHandlerTest; |
| 194 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); | 195 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
| 195 }; | 196 }; |
| 196 | 197 |
| 197 } // namespace content | 198 } // namespace content |
| 198 | 199 |
| 199 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 200 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| OLD | NEW |