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

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

Issue 207163002: more uma stats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_url_request_job.h" 5 #include "webkit/browser/appcache/appcache_url_request_job.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 15 matching lines...) Expand all
26 #include "webkit/browser/appcache/appcache_histograms.h" 26 #include "webkit/browser/appcache/appcache_histograms.h"
27 #include "webkit/browser/appcache/appcache_host.h" 27 #include "webkit/browser/appcache/appcache_host.h"
28 #include "webkit/browser/appcache/appcache_service.h" 28 #include "webkit/browser/appcache/appcache_service.h"
29 29
30 namespace appcache { 30 namespace appcache {
31 31
32 AppCacheURLRequestJob::AppCacheURLRequestJob( 32 AppCacheURLRequestJob::AppCacheURLRequestJob(
33 net::URLRequest* request, 33 net::URLRequest* request,
34 net::NetworkDelegate* network_delegate, 34 net::NetworkDelegate* network_delegate,
35 AppCacheStorage* storage, 35 AppCacheStorage* storage,
36 AppCacheHost* host) 36 AppCacheHost* host,
37 bool is_main_resource)
37 : net::URLRequestJob(request, network_delegate), 38 : net::URLRequestJob(request, network_delegate),
38 host_(host), 39 host_(host),
39 storage_(storage), 40 storage_(storage),
40 has_been_started_(false), has_been_killed_(false), 41 has_been_started_(false), has_been_killed_(false),
41 delivery_type_(AWAITING_DELIVERY_ORDERS), 42 delivery_type_(AWAITING_DELIVERY_ORDERS),
42 group_id_(0), cache_id_(kNoCacheId), is_fallback_(false), 43 group_id_(0), cache_id_(kNoCacheId), is_fallback_(false),
44 is_main_resource_(is_main_resource),
43 cache_entry_not_found_(false), 45 cache_entry_not_found_(false),
44 weak_factory_(this) { 46 weak_factory_(this) {
45 DCHECK(storage_); 47 DCHECK(storage_);
46 } 48 }
47 49
48 void AppCacheURLRequestJob::DeliverAppCachedResponse( 50 void AppCacheURLRequestJob::DeliverAppCachedResponse(
49 const GURL& manifest_url, int64 group_id, int64 cache_id, 51 const GURL& manifest_url, int64 group_id, int64 cache_id,
50 const AppCacheEntry& entry, bool is_fallback) { 52 const AppCacheEntry& entry, bool is_fallback) {
51 DCHECK(!has_delivery_orders()); 53 DCHECK(!has_delivery_orders());
52 DCHECK(entry.has_response_id()); 54 DCHECK(entry.has_response_id());
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 NotifyHeadersComplete(); 282 NotifyHeadersComplete();
281 } else { 283 } else {
282 if (storage_->service()->storage() == storage_) { 284 if (storage_->service()->storage() == storage_) {
283 // A resource that is expected to be in the appcache is missing. 285 // A resource that is expected to be in the appcache is missing.
284 // See http://code.google.com/p/chromium/issues/detail?id=50657 286 // See http://code.google.com/p/chromium/issues/detail?id=50657
285 // Instead of failing the request, we restart the request. The retry 287 // Instead of failing the request, we restart the request. The retry
286 // attempt will fallthru to the network instead of trying to load 288 // attempt will fallthru to the network instead of trying to load
287 // from the appcache. 289 // from the appcache.
288 storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_, 290 storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_,
289 entry_.response_id()); 291 entry_.response_id());
292 AppCacheHistograms::CountResponseRetrieval(
293 false, is_main_resource_, manifest_url_.GetOrigin());
290 } 294 }
291 cache_entry_not_found_ = true; 295 cache_entry_not_found_ = true;
292 NotifyRestartRequired(); 296 NotifyRestartRequired();
293 } 297 }
294 } 298 }
295 299
296 const net::HttpResponseInfo* AppCacheURLRequestJob::http_info() const { 300 const net::HttpResponseInfo* AppCacheURLRequestJob::http_info() const {
297 if (!info_.get()) 301 if (!info_.get())
298 return NULL; 302 return NULL;
299 if (range_response_info_) 303 if (range_response_info_)
(...skipping 24 matching lines...) Expand all
324 new net::HttpResponseInfo(*info_->http_response_info())); 328 new net::HttpResponseInfo(*info_->http_response_info()));
325 net::HttpResponseHeaders* headers = range_response_info_->headers.get(); 329 net::HttpResponseHeaders* headers = range_response_info_->headers.get();
326 headers->UpdateWithNewRange( 330 headers->UpdateWithNewRange(
327 range_requested_, resource_size, true /* replace status line */); 331 range_requested_, resource_size, true /* replace status line */);
328 } 332 }
329 333
330 void AppCacheURLRequestJob::OnReadComplete(int result) { 334 void AppCacheURLRequestJob::OnReadComplete(int result) {
331 DCHECK(is_delivering_appcache_response()); 335 DCHECK(is_delivering_appcache_response());
332 if (result == 0) { 336 if (result == 0) {
333 NotifyDone(net::URLRequestStatus()); 337 NotifyDone(net::URLRequestStatus());
338 AppCacheHistograms::CountResponseRetrieval(
339 true, is_main_resource_, manifest_url_.GetOrigin());
334 } else if (result < 0) { 340 } else if (result < 0) {
335 if (storage_->service()->storage() == storage_) { 341 if (storage_->service()->storage() == storage_) {
336 storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_, 342 storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_,
337 entry_.response_id()); 343 entry_.response_id());
338 } 344 }
339 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result)); 345 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
346 AppCacheHistograms::CountResponseRetrieval(
347 false, is_main_resource_, manifest_url_.GetOrigin());
340 } else { 348 } else {
341 SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status 349 SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
342 } 350 }
343 NotifyReadComplete(result); 351 NotifyReadComplete(result);
344 } 352 }
345 353
346 // net::URLRequestJob overrides ------------------------------------------------ 354 // net::URLRequestJob overrides ------------------------------------------------
347 355
348 void AppCacheURLRequestJob::Start() { 356 void AppCacheURLRequestJob::Start() {
349 DCHECK(!has_been_started()); 357 DCHECK(!has_been_started());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 return; 439 return;
432 } 440 }
433 441
434 // If multiple ranges are requested, we play dumb and 442 // If multiple ranges are requested, we play dumb and
435 // return the entire response with 200 OK. 443 // return the entire response with 200 OK.
436 if (ranges.size() == 1U) 444 if (ranges.size() == 1U)
437 range_requested_ = ranges[0]; 445 range_requested_ = ranges[0];
438 } 446 }
439 447
440 } // namespace appcache 448 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/browser/appcache/appcache_url_request_job.h ('k') | webkit/browser/appcache/appcache_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698