| 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> |
| 9 |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 11 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 12 #include "content/browser/appcache/appcache_entry.h" | 15 #include "content/browser/appcache/appcache_entry.h" |
| 13 #include "content/browser/appcache/appcache_host.h" | 16 #include "content/browser/appcache/appcache_host.h" |
| 14 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 15 #include "content/public/common/resource_type.h" | 18 #include "content/public/common/resource_type.h" |
| 16 | 19 |
| 17 namespace net { | 20 namespace net { |
| 18 class NetworkDelegate; | 21 class NetworkDelegate; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 net::URLRequest* request, | 44 net::URLRequest* request, |
| 42 net::NetworkDelegate* network_delegate); | 45 net::NetworkDelegate* network_delegate); |
| 43 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect( | 46 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect( |
| 44 net::URLRequest* request, | 47 net::URLRequest* request, |
| 45 net::NetworkDelegate* network_delegate, | 48 net::NetworkDelegate* network_delegate, |
| 46 const GURL& location); | 49 const GURL& location); |
| 47 AppCacheURLRequestJob* MaybeLoadFallbackForResponse( | 50 AppCacheURLRequestJob* MaybeLoadFallbackForResponse( |
| 48 net::URLRequest* request, | 51 net::URLRequest* request, |
| 49 net::NetworkDelegate* network_delegate); | 52 net::NetworkDelegate* network_delegate); |
| 50 | 53 |
| 51 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); | 54 void GetExtraResponseInfo(int64_t* cache_id, GURL* manifest_url); |
| 52 | 55 |
| 53 // Methods to support cross site navigations. | 56 // Methods to support cross site navigations. |
| 54 void PrepareForCrossSiteTransfer(int old_process_id); | 57 void PrepareForCrossSiteTransfer(int old_process_id); |
| 55 void CompleteCrossSiteTransfer(int new_process_id, int new_host_id); | 58 void CompleteCrossSiteTransfer(int new_process_id, int new_host_id); |
| 56 void MaybeCompleteCrossSiteTransferInOldProcess(int old_process_id); | 59 void MaybeCompleteCrossSiteTransferInOldProcess(int old_process_id); |
| 57 | 60 |
| 58 static bool IsMainResourceType(ResourceType type) { | 61 static bool IsMainResourceType(ResourceType type) { |
| 59 return IsResourceTypeFrame(type) || | 62 return IsResourceTypeFrame(type) || |
| 60 type == RESOURCE_TYPE_SHARED_WORKER; | 63 type == RESOURCE_TYPE_SHARED_WORKER; |
| 61 } | 64 } |
| 62 | 65 |
| 63 private: | 66 private: |
| 64 friend class AppCacheHost; | 67 friend class AppCacheHost; |
| 65 | 68 |
| 66 // Callers should use AppCacheHost::CreateRequestHandler. | 69 // Callers should use AppCacheHost::CreateRequestHandler. |
| 67 AppCacheRequestHandler(AppCacheHost* host, ResourceType resource_type, | 70 AppCacheRequestHandler(AppCacheHost* host, ResourceType resource_type, |
| 68 bool should_reset_appcache); | 71 bool should_reset_appcache); |
| 69 | 72 |
| 70 // AppCacheHost::Observer override | 73 // AppCacheHost::Observer override |
| 71 void OnDestructionImminent(AppCacheHost* host) override; | 74 void OnDestructionImminent(AppCacheHost* host) override; |
| 72 | 75 |
| 73 // Helpers to instruct a waiting job with what response to | 76 // Helpers to instruct a waiting job with what response to |
| 74 // deliver for the request we're handling. | 77 // deliver for the request we're handling. |
| 75 void DeliverAppCachedResponse(const AppCacheEntry& entry, int64 cache_id, | 78 void DeliverAppCachedResponse(const AppCacheEntry& entry, |
| 76 int64 group_id, const GURL& manifest_url, | 79 int64_t cache_id, |
| 80 int64_t group_id, |
| 81 const GURL& manifest_url, |
| 77 bool is_fallback, | 82 bool is_fallback, |
| 78 const GURL& namespace_entry_url); | 83 const GURL& namespace_entry_url); |
| 79 void DeliverNetworkResponse(); | 84 void DeliverNetworkResponse(); |
| 80 void DeliverErrorResponse(); | 85 void DeliverErrorResponse(); |
| 81 | 86 |
| 82 // Called just before the request is restarted. Grabs the reason for | 87 // Called just before the request is restarted. Grabs the reason for |
| 83 // restarting, so can correctly continue to handle the request. | 88 // restarting, so can correctly continue to handle the request. |
| 84 void OnPrepareToRestart(); | 89 void OnPrepareToRestart(); |
| 85 | 90 |
| 86 // Helper method to create an AppCacheURLRequestJob and populate job_. | 91 // Helper method to create an AppCacheURLRequestJob and populate job_. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 101 | 106 |
| 102 scoped_ptr<AppCacheURLRequestJob> MaybeLoadMainResource( | 107 scoped_ptr<AppCacheURLRequestJob> MaybeLoadMainResource( |
| 103 net::URLRequest* request, | 108 net::URLRequest* request, |
| 104 net::NetworkDelegate* network_delegate); | 109 net::NetworkDelegate* network_delegate); |
| 105 | 110 |
| 106 // AppCacheStorage::Delegate methods | 111 // AppCacheStorage::Delegate methods |
| 107 void OnMainResponseFound(const GURL& url, | 112 void OnMainResponseFound(const GURL& url, |
| 108 const AppCacheEntry& entry, | 113 const AppCacheEntry& entry, |
| 109 const GURL& fallback_url, | 114 const GURL& fallback_url, |
| 110 const AppCacheEntry& fallback_entry, | 115 const AppCacheEntry& fallback_entry, |
| 111 int64 cache_id, | 116 int64_t cache_id, |
| 112 int64 group_id, | 117 int64_t group_id, |
| 113 const GURL& mainfest_url) override; | 118 const GURL& mainfest_url) override; |
| 114 | 119 |
| 115 // Sub-resource loading ------------------------------------- | 120 // Sub-resource loading ------------------------------------- |
| 116 // Dedicated worker and all manner of sub-resources are handled here. | 121 // Dedicated worker and all manner of sub-resources are handled here. |
| 117 | 122 |
| 118 scoped_ptr<AppCacheURLRequestJob> MaybeLoadSubResource( | 123 scoped_ptr<AppCacheURLRequestJob> MaybeLoadSubResource( |
| 119 net::URLRequest* request, | 124 net::URLRequest* request, |
| 120 net::NetworkDelegate* network_delegate); | 125 net::NetworkDelegate* network_delegate); |
| 121 void ContinueMaybeLoadSubResource(); | 126 void ContinueMaybeLoadSubResource(); |
| 122 | 127 |
| 123 // AppCacheHost::Observer override | 128 // AppCacheHost::Observer override |
| 124 void OnCacheSelectionComplete(AppCacheHost* host) override; | 129 void OnCacheSelectionComplete(AppCacheHost* host) override; |
| 125 | 130 |
| 126 // Data members ----------------------------------------------- | 131 // Data members ----------------------------------------------- |
| 127 | 132 |
| 128 // What host we're servicing a request for. | 133 // What host we're servicing a request for. |
| 129 AppCacheHost* host_; | 134 AppCacheHost* host_; |
| 130 | 135 |
| 131 // Frame vs subresource vs sharedworker loads are somewhat different. | 136 // Frame vs subresource vs sharedworker loads are somewhat different. |
| 132 ResourceType resource_type_; | 137 ResourceType resource_type_; |
| 133 | 138 |
| 134 // True if corresponding AppCache group should be resetted before load. | 139 // True if corresponding AppCache group should be resetted before load. |
| 135 bool should_reset_appcache_; | 140 bool should_reset_appcache_; |
| 136 | 141 |
| 137 // Subresource requests wait until after cache selection completes. | 142 // Subresource requests wait until after cache selection completes. |
| 138 bool is_waiting_for_cache_selection_; | 143 bool is_waiting_for_cache_selection_; |
| 139 | 144 |
| 140 // Info about the type of response we found for delivery. | 145 // Info about the type of response we found for delivery. |
| 141 // These are relevant for both main and subresource requests. | 146 // These are relevant for both main and subresource requests. |
| 142 int64 found_group_id_; | 147 int64_t found_group_id_; |
| 143 int64 found_cache_id_; | 148 int64_t found_cache_id_; |
| 144 AppCacheEntry found_entry_; | 149 AppCacheEntry found_entry_; |
| 145 AppCacheEntry found_fallback_entry_; | 150 AppCacheEntry found_fallback_entry_; |
| 146 GURL found_namespace_entry_url_; | 151 GURL found_namespace_entry_url_; |
| 147 GURL found_manifest_url_; | 152 GURL found_manifest_url_; |
| 148 bool found_network_namespace_; | 153 bool found_network_namespace_; |
| 149 | 154 |
| 150 // True if a cache entry this handler attempted to return was | 155 // True if a cache entry this handler attempted to return was |
| 151 // not found in the disk cache. Once set, the handler will take | 156 // not found in the disk cache. Once set, the handler will take |
| 152 // no action on all subsequent intercept opportunities, so the | 157 // no action on all subsequent intercept opportunities, so the |
| 153 // request and any redirects will be handled by the network library. | 158 // request and any redirects will be handled by the network library. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 178 int cache_id_; | 183 int cache_id_; |
| 179 GURL manifest_url_; | 184 GURL manifest_url_; |
| 180 | 185 |
| 181 friend class content::AppCacheRequestHandlerTest; | 186 friend class content::AppCacheRequestHandlerTest; |
| 182 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); | 187 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
| 183 }; | 188 }; |
| 184 | 189 |
| 185 } // namespace content | 190 } // namespace content |
| 186 | 191 |
| 187 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 192 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| OLD | NEW |