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

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 15211004: Add histogram to measure the read deferral on crosswebsite navigation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
« no previous file with comments | « content/browser/loader/resource_loader.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/loader/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h"
9 #include "base/time/time.h" 10 #include "base/time/time.h"
10 #include "content/browser/child_process_security_policy_impl.h" 11 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/loader/doomed_resource_handler.h" 12 #include "content/browser/loader/doomed_resource_handler.h"
12 #include "content/browser/loader/resource_loader_delegate.h" 13 #include "content/browser/loader/resource_loader_delegate.h"
13 #include "content/browser/loader/resource_request_info_impl.h" 14 #include "content/browser/loader/resource_request_info_impl.h"
14 #include "content/browser/ssl/ssl_client_auth_handler.h" 15 #include "content/browser/ssl/ssl_client_auth_handler.h"
15 #include "content/browser/ssl/ssl_manager.h" 16 #include "content/browser/ssl/ssl_manager.h"
16 #include "content/common/ssl_status_serialization.h" 17 #include "content/common/ssl_status_serialization.h"
17 #include "content/public/browser/cert_store.h" 18 #include "content/public/browser/cert_store.h"
18 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 19 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 !request_->ssl_info().connection_status); 554 !request_->ssl_info().connection_status);
554 } 555 }
555 556
556 delegate_->DidReceiveResponse(this); 557 delegate_->DidReceiveResponse(this);
557 558
558 bool defer = false; 559 bool defer = false;
559 if (!handler_->OnResponseStarted( 560 if (!handler_->OnResponseStarted(
560 info->GetRequestID(), response.get(), &defer)) { 561 info->GetRequestID(), response.get(), &defer)) {
561 Cancel(); 562 Cancel();
562 } else if (defer) { 563 } else if (defer) {
564 read_deferral_start_time_ = base::TimeTicks::Now();
563 deferred_stage_ = DEFERRED_READ; // Read first chunk when resumed. 565 deferred_stage_ = DEFERRED_READ; // Read first chunk when resumed.
564 } 566 }
565 } 567 }
566 568
567 void ResourceLoader::StartReading(bool is_continuation) { 569 void ResourceLoader::StartReading(bool is_continuation) {
568 int bytes_read = 0; 570 int bytes_read = 0;
569 ReadMore(&bytes_read); 571 ReadMore(&bytes_read);
570 572
571 // If IO is pending, wait for the URLRequest to call OnReadCompleted. 573 // If IO is pending, wait for the URLRequest to call OnReadCompleted.
572 if (request_->status().is_io_pending()) 574 if (request_->status().is_io_pending())
573 return; 575 return;
574 576
575 if (!is_continuation || bytes_read <= 0) { 577 if (!is_continuation || bytes_read <= 0) {
576 OnReadCompleted(request_.get(), bytes_read); 578 OnReadCompleted(request_.get(), bytes_read);
577 } else { 579 } else {
578 // Else, trigger OnReadCompleted asynchronously to avoid starving the IO 580 // Else, trigger OnReadCompleted asynchronously to avoid starving the IO
579 // thread in case the URLRequest can provide data synchronously. 581 // thread in case the URLRequest can provide data synchronously.
580 base::MessageLoop::current()->PostTask( 582 base::MessageLoop::current()->PostTask(
581 FROM_HERE, 583 FROM_HERE,
582 base::Bind(&ResourceLoader::OnReadCompleted, 584 base::Bind(&ResourceLoader::OnReadCompleted,
583 weak_ptr_factory_.GetWeakPtr(), 585 weak_ptr_factory_.GetWeakPtr(),
584 request_.get(), 586 request_.get(),
585 bytes_read)); 587 bytes_read));
586 } 588 }
587 } 589 }
588 590
589 void ResourceLoader::ResumeReading() { 591 void ResourceLoader::ResumeReading() {
590 DCHECK(!is_deferred()); 592 DCHECK(!is_deferred());
591 593
594 if (!read_deferral_start_time_.is_null()) {
595 UMA_HISTOGRAM_TIMES("Net.ResourceLoader.ReadDeferral",
596 base::TimeTicks::Now() - read_deferral_start_time_);
597 read_deferral_start_time_ = base::TimeTicks();
598 }
592 if (request_->status().is_success()) { 599 if (request_->status().is_success()) {
593 StartReading(false); // Read the next chunk (OK to complete synchronously). 600 StartReading(false); // Read the next chunk (OK to complete synchronously).
594 } else { 601 } else {
595 ResponseCompleted(); 602 ResponseCompleted();
596 } 603 }
597 } 604 }
598 605
599 void ResourceLoader::ReadMore(int* bytes_read) { 606 void ResourceLoader::ReadMore(int* bytes_read) {
600 ResourceRequestInfoImpl* info = GetRequestInfo(); 607 ResourceRequestInfoImpl* info = GetRequestInfo();
601 DCHECK(!is_deferred()); 608 DCHECK(!is_deferred());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // we resume. 660 // we resume.
654 deferred_stage_ = DEFERRED_FINISH; 661 deferred_stage_ = DEFERRED_FINISH;
655 } 662 }
656 } 663 }
657 664
658 void ResourceLoader::CallDidFinishLoading() { 665 void ResourceLoader::CallDidFinishLoading() {
659 delegate_->DidFinishLoading(this); 666 delegate_->DidFinishLoading(this);
660 } 667 }
661 668
662 } // namespace content 669 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_loader.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698