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

Side by Side Diff: chrome/renderer/page_load_histograms.cc

Issue 2379293002: Rename RFO::FrameWillClose() to reflect its actual purpose. (Closed)
Patch Set: Fix silly typo Created 4 years, 2 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
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 // TODO(bmcquade): delete this class in October 2016, as it is deprecated by the 5 // TODO(bmcquade): delete this class in October 2016, as it is deprecated by the
6 // new PageLoad.* UMA histograms. 6 // new PageLoad.* UMA histograms.
7 7
8 #include "chrome/renderer/page_load_histograms.h" 8 #include "chrome/renderer/page_load_histograms.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 19 matching lines...) Expand all
30 #include "content/public/renderer/render_frame.h" 30 #include "content/public/renderer/render_frame.h"
31 #include "content/public/renderer/render_thread.h" 31 #include "content/public/renderer/render_thread.h"
32 #include "content/public/renderer/render_view.h" 32 #include "content/public/renderer/render_view.h"
33 #include "extensions/common/url_pattern.h" 33 #include "extensions/common/url_pattern.h"
34 #include "net/base/url_util.h" 34 #include "net/base/url_util.h"
35 #include "net/http/http_response_headers.h" 35 #include "net/http/http_response_headers.h"
36 #include "third_party/WebKit/public/platform/URLConversion.h" 36 #include "third_party/WebKit/public/platform/URLConversion.h"
37 #include "third_party/WebKit/public/platform/WebURLRequest.h" 37 #include "third_party/WebKit/public/platform/WebURLRequest.h"
38 #include "third_party/WebKit/public/platform/WebURLResponse.h" 38 #include "third_party/WebKit/public/platform/WebURLResponse.h"
39 #include "third_party/WebKit/public/web/WebDocument.h" 39 #include "third_party/WebKit/public/web/WebDocument.h"
40 #include "third_party/WebKit/public/web/WebFrame.h" 40 #include "third_party/WebKit/public/web/WebLocalFrame.h"
41 #include "third_party/WebKit/public/web/WebPerformance.h" 41 #include "third_party/WebKit/public/web/WebPerformance.h"
42 #include "third_party/WebKit/public/web/WebView.h" 42 #include "third_party/WebKit/public/web/WebView.h"
43 #include "url/gurl.h" 43 #include "url/gurl.h"
44 44
45 #if defined(ENABLE_EXTENSIONS) 45 #if defined(ENABLE_EXTENSIONS)
46 #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h" 46 #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h"
47 #include "extensions/renderer/dispatcher.h" 47 #include "extensions/renderer/dispatcher.h"
48 #endif 48 #endif
49 49
50 using blink::WebDataSource; 50 using blink::WebDataSource;
51 using blink::WebFrame; 51 using blink::WebLocalFrame;
52 using blink::WebPerformance; 52 using blink::WebPerformance;
53 using blink::WebString; 53 using blink::WebString;
54 using base::Time; 54 using base::Time;
55 using base::TimeDelta; 55 using base::TimeDelta;
56 using content::DocumentState; 56 using content::DocumentState;
57 57
58 const size_t kPLTCount = 100; 58 const size_t kPLTCount = 100;
59 59
60 namespace { 60 namespace {
61 61
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) { 126 URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) {
127 if (url.SchemeIs("http")) 127 if (url.SchemeIs("http"))
128 return URLPattern::SCHEME_HTTP; 128 return URLPattern::SCHEME_HTTP;
129 else if (url.SchemeIs("https")) 129 else if (url.SchemeIs("https"))
130 return URLPattern::SCHEME_HTTPS; 130 return URLPattern::SCHEME_HTTPS;
131 return static_cast<URLPattern::SchemeMasks>(0); 131 return static_cast<URLPattern::SchemeMasks>(0);
132 } 132 }
133 133
134 // Helper function to check for string in 'via' header. Returns true if 134 // Helper function to check for string in 'via' header. Returns true if
135 // |via_value| is one of the values listed in the Via header. 135 // |via_value| is one of the values listed in the Via header.
136 bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) { 136 bool ViaHeaderContains(WebLocalFrame* frame, const std::string& via_value) {
137 const char kViaHeaderName[] = "Via"; 137 const char kViaHeaderName[] = "Via";
138 std::vector<std::string> values; 138 std::vector<std::string> values;
139 // Multiple via headers have already been coalesced and hence each value 139 // Multiple via headers have already been coalesced and hence each value
140 // separated by a comma corresponds to a proxy. The value added by a proxy is 140 // separated by a comma corresponds to a proxy. The value added by a proxy is
141 // not expected to contain any commas. 141 // not expected to contain any commas.
142 // Example., Via: 1.0 Compression proxy, 1.1 Google Instant Proxy Preview 142 // Example., Via: 1.0 Compression proxy, 1.1 Google Instant Proxy Preview
143 values = base::SplitString( 143 values = base::SplitString(
144 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(), 144 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(),
145 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 145 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
146 return std::find(values.begin(), values.end(), via_value) != values.end(); 146 return std::find(values.begin(), values.end(), via_value) != values.end();
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 begin_to_finish_all_loads); 521 begin_to_finish_all_loads);
522 break; 522 break;
523 default: 523 default:
524 break; 524 break;
525 } 525 }
526 } 526 }
527 } 527 }
528 528
529 } // namespace 529 } // namespace
530 530
531 PageLoadHistograms::PageLoadHistograms(content::RenderView* render_view) 531 PageLoadHistograms::PageLoadHistograms(content::RenderFrame* render_frame)
532 : content::RenderViewObserver(render_view) { 532 : content::RenderFrameObserver(render_frame), helper_(this) {}
533 }
534 533
535 PageLoadHistograms::~PageLoadHistograms() { 534 PageLoadHistograms::~PageLoadHistograms() {
536 } 535 }
537 536
538 void PageLoadHistograms::Dump(WebFrame* frame) { 537 void PageLoadHistograms::Dump() {
538 WebLocalFrame* frame = render_frame()->GetWebFrame();
539
539 // We only dump histograms for main frames. 540 // We only dump histograms for main frames.
540 // In the future, it may be interesting to tag subframes and dump them too. 541 // In the future, it may be interesting to tag subframes and dump them too.
541 if (!frame || frame->parent()) 542 DCHECK(frame && !frame->parent());
542 return;
543
544 // If the main frame lives in a different process, don't do anything.
545 // Histogram data will be recorded by the real main frame.
546 if (frame->isWebRemoteFrame())
547 return;
548 543
549 // Only dump for supported schemes. 544 // Only dump for supported schemes.
550 URLPattern::SchemeMasks scheme_type = 545 URLPattern::SchemeMasks scheme_type =
551 GetSupportedSchemeType(frame->document().url()); 546 GetSupportedSchemeType(frame->document().url());
552 if (scheme_type == 0) 547 if (scheme_type == 0)
553 return; 548 return;
554 549
555 // Don't dump stats for the NTP, as PageLoadHistograms should only be recorded 550 // Don't dump stats for the NTP, as PageLoadHistograms should only be recorded
556 // for pages visited due to an explicit user navigation. 551 // for pages visited due to an explicit user navigation.
557 if (SearchBouncer::GetInstance()->IsNewTabPage(frame->document().url())) { 552 if (SearchBouncer::GetInstance()->IsNewTabPage(frame->document().url())) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 // sure that we send the histograms generated. Without this call, pages 585 // sure that we send the histograms generated. Without this call, pages
591 // that don't have an on-close-handler might generate data that is lost if 586 // that don't have an on-close-handler might generate data that is lost if
592 // the renderer is shutdown abruptly (e.g. the user closed the tab). 587 // the renderer is shutdown abruptly (e.g. the user closed the tab).
593 // TODO(bcwhite): Remove completely when persistence is on-by-default. 588 // TODO(bcwhite): Remove completely when persistence is on-by-default.
594 if (!base::GlobalHistogramAllocator::Get()) { 589 if (!base::GlobalHistogramAllocator::Get()) {
595 content::RenderThread::Get()->UpdateHistograms( 590 content::RenderThread::Get()->UpdateHistograms(
596 content::kHistogramSynchronizerReservedSequenceNumber); 591 content::kHistogramSynchronizerReservedSequenceNumber);
597 } 592 }
598 } 593 }
599 594
600 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { 595 void PageLoadHistograms::WillCommitProvisionalLoad() {
601 Dump(frame); 596 Dump();
602 }
603
604 void PageLoadHistograms::ClosePage() {
605 // TODO(davemoore) This code should be removed once willClose() gets
606 // called when a page is destroyed. page_load_histograms_.Dump() is safe
607 // to call multiple times for the same frame, but it will simplify things.
608 Dump(render_view()->GetWebView()->mainFrame());
609 } 597 }
610 598
611 void PageLoadHistograms::LogPageLoadTime(const DocumentState* document_state, 599 void PageLoadHistograms::LogPageLoadTime(const DocumentState* document_state,
612 const WebDataSource* ds) const { 600 const WebDataSource* ds) const {
613 // Because this function gets called on every page load, 601 // Because this function gets called on every page load,
614 // take extra care to optimize it away if logging is turned off. 602 // take extra care to optimize it away if logging is turned off.
615 if (logging::LOG_INFO < logging::GetMinLogLevel()) 603 if (logging::LOG_INFO < logging::GetMinLogLevel())
616 return; 604 return;
617 605
618 DCHECK(document_state); 606 DCHECK(document_state);
619 DCHECK(ds); 607 DCHECK(ds);
620 GURL url(ds->request().url()); 608 GURL url(ds->request().url());
621 Time start = document_state->start_load_time(); 609 Time start = document_state->start_load_time();
622 Time finish = document_state->finish_load_time(); 610 Time finish = document_state->finish_load_time();
623 // TODO(mbelshe): should we log more stats? 611 // TODO(mbelshe): should we log more stats?
624 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " 612 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms "
625 << url.spec(); 613 << url.spec();
626 } 614 }
627 615
628 void PageLoadHistograms::OnDestruct() { 616 void PageLoadHistograms::OnDestruct() {
629 delete this; 617 delete this;
630 } 618 }
619
620 PageLoadHistograms::Helper::Helper(PageLoadHistograms* histograms)
621 : RenderViewObserver(histograms->render_frame()->GetRenderView()),
622 histograms_(histograms) {
623 }
624
625 void PageLoadHistograms::Helper::ClosePage() {
626 histograms_->Dump();
627 }
628
629 void PageLoadHistograms::Helper::OnDestruct() {
630 }
OLDNEW
« no previous file with comments | « chrome/renderer/page_load_histograms.h ('k') | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698