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

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, 7 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 "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.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h"
9 #include "base/time.h" 10 #include "base/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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void ResourceLoader::Init(scoped_ptr<net::URLRequest> request, 207 void ResourceLoader::Init(scoped_ptr<net::URLRequest> request,
207 scoped_ptr<ResourceHandler> handler, 208 scoped_ptr<ResourceHandler> handler,
208 ResourceLoaderDelegate* delegate, 209 ResourceLoaderDelegate* delegate,
209 scoped_ptr<net::ClientCertStore> client_cert_store) { 210 scoped_ptr<net::ClientCertStore> client_cert_store) {
210 deferred_stage_ = DEFERRED_NONE; 211 deferred_stage_ = DEFERRED_NONE;
211 request_ = request.Pass(); 212 request_ = request.Pass();
212 handler_ = handler.Pass(); 213 handler_ = handler.Pass();
213 delegate_ = delegate; 214 delegate_ = delegate;
214 last_upload_position_ = 0; 215 last_upload_position_ = 0;
215 waiting_for_upload_progress_ack_ = false; 216 waiting_for_upload_progress_ack_ = false;
217 compute_read_deferral_histogram_ = false;
216 is_transferring_ = false; 218 is_transferring_ = false;
217 client_cert_store_ = client_cert_store.Pass(); 219 client_cert_store_ = client_cert_store.Pass();
218 220
219 request_->set_delegate(this); 221 request_->set_delegate(this);
220 handler_->SetController(this); 222 handler_->SetController(this);
221 } 223 }
222 224
223 void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, 225 void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused,
224 const GURL& new_url, 226 const GURL& new_url,
225 bool* defer) { 227 bool* defer) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 357 }
356 358
357 // We want to send a final upload progress message prior to sending the 359 // We want to send a final upload progress message prior to sending the
358 // response complete message even if we're waiting for an ack to to a 360 // response complete message even if we're waiting for an ack to to a
359 // previous upload progress message. 361 // previous upload progress message.
360 waiting_for_upload_progress_ack_ = false; 362 waiting_for_upload_progress_ack_ = false;
361 ReportUploadProgress(); 363 ReportUploadProgress();
362 364
363 CompleteResponseStarted(); 365 CompleteResponseStarted();
364 366
365 if (is_deferred()) 367 if (is_deferred()) {
368 compute_read_deferral_histogram_ = true;
pasko 2013/05/21 16:37:51 I think reflecting the state rather than intention
James Simonsen 2013/08/01 19:17:40 I don't think you need this bool at all. Just chec
clamy 2013/08/05 14:33:44 Done.
369 deferral_time_ = base::TimeTicks::Now();
pasko 2013/05/21 16:37:51 this would sound more logical with the name respon
366 return; 370 return;
371 }
367 372
368 if (request_->status().is_success()) { 373 if (request_->status().is_success()) {
369 StartReading(false); // Read the first chunk. 374 StartReading(false); // Read the first chunk.
370 } else { 375 } else {
371 ResponseCompleted(); 376 ResponseCompleted();
372 } 377 }
373 } 378 }
374 379
375 void ResourceLoader::OnReadCompleted(net::URLRequest* unused, int bytes_read) { 380 void ResourceLoader::OnReadCompleted(net::URLRequest* unused, int bytes_read) {
376 DCHECK_EQ(request_.get(), unused); 381 DCHECK_EQ(request_.get(), unused);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 request_->ssl_info().security_bits == -1 && 554 request_->ssl_info().security_bits == -1 &&
550 !request_->ssl_info().connection_status); 555 !request_->ssl_info().connection_status);
551 } 556 }
552 557
553 delegate_->DidReceiveResponse(this); 558 delegate_->DidReceiveResponse(this);
554 559
555 bool defer = false; 560 bool defer = false;
556 if (!handler_->OnResponseStarted(info->GetRequestID(), response, &defer)) { 561 if (!handler_->OnResponseStarted(info->GetRequestID(), response, &defer)) {
557 Cancel(); 562 Cancel();
558 } else if (defer) { 563 } else if (defer) {
559 deferred_stage_ = DEFERRED_READ; // Read first chunk when resumed. 564 deferred_stage_ = DEFERRED_READ; // Read first chunk when resumed.
James Simonsen 2013/08/01 19:17:40 Seems like it'd make more sense to set deferral_ti
clamy 2013/08/05 14:33:44 Done.
560 } 565 }
561 } 566 }
562 567
563 void ResourceLoader::StartReading(bool is_continuation) { 568 void ResourceLoader::StartReading(bool is_continuation) {
564 int bytes_read = 0; 569 int bytes_read = 0;
565 ReadMore(&bytes_read); 570 ReadMore(&bytes_read);
566 571
567 // If IO is pending, wait for the URLRequest to call OnReadCompleted. 572 // If IO is pending, wait for the URLRequest to call OnReadCompleted.
568 if (request_->status().is_io_pending()) 573 if (request_->status().is_io_pending())
569 return; 574 return;
570 575
571 if (!is_continuation || bytes_read <= 0) { 576 if (!is_continuation || bytes_read <= 0) {
572 OnReadCompleted(request_.get(), bytes_read); 577 OnReadCompleted(request_.get(), bytes_read);
573 } else { 578 } else {
574 // Else, trigger OnReadCompleted asynchronously to avoid starving the IO 579 // Else, trigger OnReadCompleted asynchronously to avoid starving the IO
575 // thread in case the URLRequest can provide data synchronously. 580 // thread in case the URLRequest can provide data synchronously.
576 base::MessageLoop::current()->PostTask( 581 base::MessageLoop::current()->PostTask(
577 FROM_HERE, 582 FROM_HERE,
578 base::Bind(&ResourceLoader::OnReadCompleted, 583 base::Bind(&ResourceLoader::OnReadCompleted,
579 weak_ptr_factory_.GetWeakPtr(), 584 weak_ptr_factory_.GetWeakPtr(),
580 request_.get(), 585 request_.get(),
581 bytes_read)); 586 bytes_read));
582 } 587 }
583 } 588 }
584 589
585 void ResourceLoader::ResumeReading() { 590 void ResourceLoader::ResumeReading() {
586 DCHECK(!is_deferred()); 591 DCHECK(!is_deferred());
587 592
593 if (compute_read_deferral_histogram_) {
594 compute_read_deferral_histogram_ = false;
595 UMA_HISTOGRAM_TIMES("Net.ResourceLoader.ReadDeferral",
pasko 2013/05/21 16:37:51 please also add a pairing change in: tools/metrics
596 base::TimeTicks::Now() - deferral_time_);
597 }
588 if (request_->status().is_success()) { 598 if (request_->status().is_success()) {
589 StartReading(false); // Read the next chunk (OK to complete synchronously). 599 StartReading(false); // Read the next chunk (OK to complete synchronously).
590 } else { 600 } else {
591 ResponseCompleted(); 601 ResponseCompleted();
592 } 602 }
593 } 603 }
594 604
595 void ResourceLoader::ReadMore(int* bytes_read) { 605 void ResourceLoader::ReadMore(int* bytes_read) {
596 ResourceRequestInfoImpl* info = GetRequestInfo(); 606 ResourceRequestInfoImpl* info = GetRequestInfo();
597 DCHECK(!is_deferred()); 607 DCHECK(!is_deferred());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // we resume. 659 // we resume.
650 deferred_stage_ = DEFERRED_FINISH; 660 deferred_stage_ = DEFERRED_FINISH;
651 } 661 }
652 } 662 }
653 663
654 void ResourceLoader::CallDidFinishLoading() { 664 void ResourceLoader::CallDidFinishLoading() {
655 delegate_->DidFinishLoading(this); 665 delegate_->DidFinishLoading(this);
656 } 666 }
657 667
658 } // namespace content 668 } // namespace content
OLDNEW
« content/browser/loader/resource_loader.h ('K') | « content/browser/loader/resource_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698