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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Add Finch trial check and rebase Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 return UserInitiatedInfo::RenderInitiated( 58 return UserInitiatedInfo::RenderInitiated(
59 navigation_handle->HasUserGesture(), 59 navigation_handle->HasUserGesture(),
60 committed_load && 60 committed_load &&
61 committed_load->input_tracker()->FindAndConsumeInputEventsBefore( 61 committed_load->input_tracker()->FindAndConsumeInputEventsBefore(
62 navigation_handle->NavigationStart())); 62 navigation_handle->NavigationStart()));
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 // static
68 MetricsWebContentsObserver::MetricsWebContentsObserver( 67 MetricsWebContentsObserver::MetricsWebContentsObserver(
69 content::WebContents* web_contents, 68 content::WebContents* web_contents,
70 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) 69 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface)
71 : content::WebContentsObserver(web_contents), 70 : content::WebContentsObserver(web_contents),
72 in_foreground_(false), 71 in_foreground_(false),
73 embedder_interface_(std::move(embedder_interface)), 72 embedder_interface_(std::move(embedder_interface)),
74 has_navigated_(false) { 73 has_navigated_(false),
74 page_load_metrics_binding_(web_contents, this) {
75 RegisterInputEventObserver(web_contents->GetRenderViewHost()); 75 RegisterInputEventObserver(web_contents->GetRenderViewHost());
76 } 76 }
77 77
78 // static
78 MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents( 79 MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents(
79 content::WebContents* web_contents, 80 content::WebContents* web_contents,
80 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) { 81 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) {
81 DCHECK(web_contents); 82 DCHECK(web_contents);
82 83
83 MetricsWebContentsObserver* metrics = FromWebContents(web_contents); 84 MetricsWebContentsObserver* metrics = FromWebContents(web_contents);
84 if (!metrics) { 85 if (!metrics) {
85 metrics = new MetricsWebContentsObserver(web_contents, 86 metrics = new MetricsWebContentsObserver(web_contents,
86 std::move(embedder_interface)); 87 std::move(embedder_interface));
87 web_contents->SetUserData(UserDataKey(), metrics); 88 web_contents->SetUserData(UserDataKey(), metrics);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // updates. 574 // updates.
574 if (!timing.IsEmpty()) 575 if (!timing.IsEmpty())
575 RecordInternalError(ERR_TIMING_IPC_FROM_SUBFRAME); 576 RecordInternalError(ERR_TIMING_IPC_FROM_SUBFRAME);
576 committed_load_->UpdateChildFrameMetadata(metadata); 577 committed_load_->UpdateChildFrameMetadata(metadata);
577 return; 578 return;
578 } 579 }
579 580
580 committed_load_->UpdateTiming(timing, metadata); 581 committed_load_->UpdateTiming(timing, metadata);
581 } 582 }
582 583
584 void MetricsWebContentsObserver::UpdateTiming(
585 const PageLoadTiming& timing,
586 const PageLoadMetadata& metadata) {
587 content::RenderFrameHost* render_frame_host =
588 page_load_metrics_binding_.GetCurrentTargetFrame();
589 OnTimingUpdated(render_frame_host, timing, metadata);
Zhen Wang 2017/04/19 18:49:54 This is using the same timing update function as t
Zhen Wang 2017/04/19 18:56:31 I just realized that you may not need to do any sp
590 }
591
583 bool MetricsWebContentsObserver::ShouldTrackNavigation( 592 bool MetricsWebContentsObserver::ShouldTrackNavigation(
584 content::NavigationHandle* navigation_handle) const { 593 content::NavigationHandle* navigation_handle) const {
585 DCHECK(navigation_handle->IsInMainFrame()); 594 DCHECK(navigation_handle->IsInMainFrame());
586 DCHECK(!navigation_handle->HasCommitted() || 595 DCHECK(!navigation_handle->HasCommitted() ||
587 !navigation_handle->IsSameDocument()); 596 !navigation_handle->IsSameDocument());
588 597
589 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 598 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
590 navigation_handle).ShouldTrack(); 599 navigation_handle).ShouldTrack();
591 } 600 }
592 601
593 } // namespace page_load_metrics 602 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698