Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: webkit/browser/appcache/appcache_request_handler.cc

Issue 207163002: more uma stats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "webkit/browser/appcache/appcache_request_handler.h" 5 #include "webkit/browser/appcache/appcache_request_handler.h"
6 6
7 #include "net/url_request/url_request.h" 7 #include "net/url_request/url_request.h"
8 #include "net/url_request/url_request_job.h" 8 #include "net/url_request/url_request_job.h"
9 #include "webkit/browser/appcache/appcache.h" 9 #include "webkit/browser/appcache/appcache.h"
10 #include "webkit/browser/appcache/appcache_backend_impl.h" 10 #include "webkit/browser/appcache/appcache_backend_impl.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return NULL; 96 return NULL;
97 if (request->url().GetOrigin() == location.GetOrigin()) 97 if (request->url().GetOrigin() == location.GetOrigin())
98 return NULL; 98 return NULL;
99 99
100 DCHECK(!job_.get()); // our jobs never generate redirects 100 DCHECK(!job_.get()); // our jobs never generate redirects
101 101
102 if (found_fallback_entry_.has_response_id()) { 102 if (found_fallback_entry_.has_response_id()) {
103 // 6.9.6, step 4: If this results in a redirect to another origin, 103 // 6.9.6, step 4: If this results in a redirect to another origin,
104 // get the resource of the fallback entry. 104 // get the resource of the fallback entry.
105 job_ = new AppCacheURLRequestJob(request, network_delegate, 105 job_ = new AppCacheURLRequestJob(request, network_delegate,
106 storage(), host_); 106 storage(), host_, is_main_resource());
107 DeliverAppCachedResponse( 107 DeliverAppCachedResponse(
108 found_fallback_entry_, found_cache_id_, found_group_id_, 108 found_fallback_entry_, found_cache_id_, found_group_id_,
109 found_manifest_url_, true, found_namespace_entry_url_); 109 found_manifest_url_, true, found_namespace_entry_url_);
110 } else if (!found_network_namespace_) { 110 } else if (!found_network_namespace_) {
111 // 6.9.6, step 6: Fail the resource load. 111 // 6.9.6, step 6: Fail the resource load.
112 job_ = new AppCacheURLRequestJob(request, network_delegate, 112 job_ = new AppCacheURLRequestJob(request, network_delegate,
113 storage(), host_); 113 storage(), host_, is_main_resource());
114 DeliverErrorResponse(); 114 DeliverErrorResponse();
115 } else { 115 } else {
116 // 6.9.6 step 3 and 5: Fetch the resource normally. 116 // 6.9.6 step 3 and 5: Fetch the resource normally.
117 } 117 }
118 118
119 return job_.get(); 119 return job_.get();
120 } 120 }
121 121
122 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse( 122 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse(
123 net::URLRequest* request, net::NetworkDelegate* network_delegate) { 123 net::URLRequest* request, net::NetworkDelegate* network_delegate) {
(...skipping 25 matching lines...) Expand all
149 "disallow-fallback"); 149 "disallow-fallback");
150 std::string header_value; 150 std::string header_value;
151 request->GetResponseHeaderByName(kFallbackOverrideHeader, &header_value); 151 request->GetResponseHeaderByName(kFallbackOverrideHeader, &header_value);
152 if (header_value == kFallbackOverrideValue) 152 if (header_value == kFallbackOverrideValue)
153 return NULL; 153 return NULL;
154 } 154 }
155 155
156 // 6.9.6, step 4: If this results in a 4xx or 5xx status code 156 // 6.9.6, step 4: If this results in a 4xx or 5xx status code
157 // or there were network errors, get the resource of the fallback entry. 157 // or there were network errors, get the resource of the fallback entry.
158 job_ = new AppCacheURLRequestJob(request, network_delegate, 158 job_ = new AppCacheURLRequestJob(request, network_delegate,
159 storage(), host_); 159 storage(), host_, is_main_resource());
160 DeliverAppCachedResponse( 160 DeliverAppCachedResponse(
161 found_fallback_entry_, found_cache_id_, found_group_id_, 161 found_fallback_entry_, found_cache_id_, found_group_id_,
162 found_manifest_url_, true, found_namespace_entry_url_); 162 found_manifest_url_, true, found_namespace_entry_url_);
163 return job_.get(); 163 return job_.get();
164 } 164 }
165 165
166 void AppCacheRequestHandler::GetExtraResponseInfo( 166 void AppCacheRequestHandler::GetExtraResponseInfo(
167 int64* cache_id, GURL* manifest_url) { 167 int64* cache_id, GURL* manifest_url) {
168 if (job_.get() && job_->is_delivering_appcache_response()) { 168 if (job_.get() && job_->is_delivering_appcache_response()) {
169 *cache_id = job_->cache_id(); 169 *cache_id = job_->cache_id();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 const AppCacheHost* spawning_host = 234 const AppCacheHost* spawning_host =
235 ResourceType::IsSharedWorker(resource_type_) ? 235 ResourceType::IsSharedWorker(resource_type_) ?
236 host_ : host_->GetSpawningHost(); 236 host_ : host_->GetSpawningHost();
237 GURL preferred_manifest_url = spawning_host ? 237 GURL preferred_manifest_url = spawning_host ?
238 spawning_host->preferred_manifest_url() : GURL(); 238 spawning_host->preferred_manifest_url() : GURL();
239 239
240 // We may have to wait for our storage query to complete, but 240 // We may have to wait for our storage query to complete, but
241 // this query can also complete syncrhonously. 241 // this query can also complete syncrhonously.
242 job_ = new AppCacheURLRequestJob(request, network_delegate, 242 job_ = new AppCacheURLRequestJob(request, network_delegate,
243 storage(), host_); 243 storage(), host_, is_main_resource());
244 storage()->FindResponseForMainRequest( 244 storage()->FindResponseForMainRequest(
245 request->url(), preferred_manifest_url, this); 245 request->url(), preferred_manifest_url, this);
246 } 246 }
247 247
248 void AppCacheRequestHandler::OnMainResponseFound( 248 void AppCacheRequestHandler::OnMainResponseFound(
249 const GURL& url, const AppCacheEntry& entry, 249 const GURL& url, const AppCacheEntry& entry,
250 const GURL& namespace_entry_url, const AppCacheEntry& fallback_entry, 250 const GURL& namespace_entry_url, const AppCacheEntry& fallback_entry,
251 int64 cache_id, int64 group_id, const GURL& manifest_url) { 251 int64 cache_id, int64 group_id, const GURL& manifest_url) {
252 DCHECK(job_.get()); 252 DCHECK(job_.get());
253 DCHECK(host_); 253 DCHECK(host_);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 void AppCacheRequestHandler::MaybeLoadSubResource( 308 void AppCacheRequestHandler::MaybeLoadSubResource(
309 net::URLRequest* request, net::NetworkDelegate* network_delegate) { 309 net::URLRequest* request, net::NetworkDelegate* network_delegate) {
310 DCHECK(!job_.get()); 310 DCHECK(!job_.get());
311 311
312 if (host_->is_selection_pending()) { 312 if (host_->is_selection_pending()) {
313 // We have to wait until cache selection is complete and the 313 // We have to wait until cache selection is complete and the
314 // selected cache is loaded. 314 // selected cache is loaded.
315 is_waiting_for_cache_selection_ = true; 315 is_waiting_for_cache_selection_ = true;
316 job_ = new AppCacheURLRequestJob(request, network_delegate, 316 job_ = new AppCacheURLRequestJob(request, network_delegate,
317 storage(), host_); 317 storage(), host_, is_main_resource());
318 return; 318 return;
319 } 319 }
320 320
321 if (!host_->associated_cache() || 321 if (!host_->associated_cache() ||
322 !host_->associated_cache()->is_complete()) { 322 !host_->associated_cache()->is_complete() ||
323 host_->associated_cache()->owning_group()->is_being_deleted()) {
jsbell 2014/03/21 16:41:02 Is this a behavior change?
michaeln 2014/03/24 18:12:04 Yes, when is_being_deleted the request is doomed t
323 return; 324 return;
324 } 325 }
325 326
326 job_ = new AppCacheURLRequestJob(request, network_delegate, 327 job_ = new AppCacheURLRequestJob(request, network_delegate,
327 storage(), host_); 328 storage(), host_, is_main_resource());
328 ContinueMaybeLoadSubResource(); 329 ContinueMaybeLoadSubResource();
329 } 330 }
330 331
331 void AppCacheRequestHandler::ContinueMaybeLoadSubResource() { 332 void AppCacheRequestHandler::ContinueMaybeLoadSubResource() {
332 // 6.9.6 Changes to the networking model 333 // 6.9.6 Changes to the networking model
333 // If the resource is not to be fetched using the HTTP GET mechanism or 334 // If the resource is not to be fetched using the HTTP GET mechanism or
334 // equivalent ... then fetch the resource normally. 335 // equivalent ... then fetch the resource normally.
335 DCHECK(job_.get()); 336 DCHECK(job_.get());
336 DCHECK(host_->associated_cache() && host_->associated_cache()->is_complete()); 337 DCHECK(host_->associated_cache() && host_->associated_cache()->is_complete());
337 338
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (!host_->associated_cache() || 390 if (!host_->associated_cache() ||
390 !host_->associated_cache()->is_complete()) { 391 !host_->associated_cache()->is_complete()) {
391 DeliverNetworkResponse(); 392 DeliverNetworkResponse();
392 return; 393 return;
393 } 394 }
394 395
395 ContinueMaybeLoadSubResource(); 396 ContinueMaybeLoadSubResource();
396 } 397 }
397 398
398 } // namespace appcache 399 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698