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

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

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Add browser test for mojofication. 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 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" 14 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
15 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h"
15 #include "chrome/common/page_load_metrics/page_load_timing.h" 16 #include "chrome/common/page_load_metrics/page_load_timing.h"
16 #include "content/public/browser/render_widget_host.h" 17 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_binding_set.h"
18 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
19 #include "content/public/browser/web_contents_user_data.h" 21 #include "content/public/browser/web_contents_user_data.h"
20 #include "content/public/common/resource_type.h" 22 #include "content/public/common/resource_type.h"
23 #include "mojo/public/cpp/bindings/binding_set.h"
21 #include "third_party/WebKit/public/platform/WebInputEvent.h" 24 #include "third_party/WebKit/public/platform/WebInputEvent.h"
22 25
23 namespace content { 26 namespace content {
24 class NavigationHandle; 27 class NavigationHandle;
25 class RenderFrameHost; 28 class RenderFrameHost;
26 } // namespace content 29 } // namespace content
27 30
28 namespace IPC { 31 namespace IPC {
29 class Message; 32 class Message;
30 } // namespace IPC 33 } // namespace IPC
31 34
32 namespace page_load_metrics { 35 namespace page_load_metrics {
33 36
34 class PageLoadMetricsEmbedderInterface; 37 class PageLoadMetricsEmbedderInterface;
35 class PageLoadTracker; 38 class PageLoadTracker;
36 39
37 // MetricsWebContentsObserver tracks page loads and loading metrics 40 // MetricsWebContentsObserver tracks page loads and loading metrics
38 // related data based on IPC messages received from a 41 // related data based on IPC messages received from a
39 // MetricsRenderFrameObserver. 42 // MetricsRenderFrameObserver.
40 class MetricsWebContentsObserver 43 class MetricsWebContentsObserver
41 : public content::WebContentsObserver, 44 : public content::WebContentsObserver,
42 public content::WebContentsUserData<MetricsWebContentsObserver>, 45 public content::WebContentsUserData<MetricsWebContentsObserver>,
43 public content::RenderWidgetHost::InputEventObserver { 46 public content::RenderWidgetHost::InputEventObserver,
47 public mojom::PageLoadMetrics {
44 public: 48 public:
45 // Note that the returned metrics is owned by the web contents. 49 // Note that the returned metrics is owned by the web contents.
46 static MetricsWebContentsObserver* CreateForWebContents( 50 static MetricsWebContentsObserver* CreateForWebContents(
47 content::WebContents* web_contents, 51 content::WebContents* web_contents,
48 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 52 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
49 MetricsWebContentsObserver( 53 MetricsWebContentsObserver(
50 content::WebContents* web_contents, 54 content::WebContents* web_contents,
51 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 55 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
52 ~MetricsWebContentsObserver() override; 56 ~MetricsWebContentsObserver() override;
53 57
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 97
94 // Flush any buffered metrics, as part of the metrics subsystem persisting 98 // Flush any buffered metrics, as part of the metrics subsystem persisting
95 // metrics as the application goes into the background. The application may be 99 // metrics as the application goes into the background. The application may be
96 // killed at any time after this method is invoked without further 100 // killed at any time after this method is invoked without further
97 // notification. 101 // notification.
98 void FlushMetricsOnAppEnterBackground(); 102 void FlushMetricsOnAppEnterBackground();
99 103
100 // This getter function is required for testing. 104 // This getter function is required for testing.
101 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 105 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
102 106
107 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics>&
108 page_load_metrics_binding_for_testing() {
109 return page_load_metrics_binding_;
110 }
111
103 private: 112 private:
104 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 113 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
114 friend class FakePageLoadMetrics;
Bryan McQuade 2017/04/25 15:41:13 i'm a bit uncomfortable about this - i need to see
115
116 // page_load_metrics::mojom::PageLoadMetrics implementation.
117 void UpdateTiming(const PageLoadTiming& timing,
118 const PageLoadMetadata& metadata) override;
105 119
106 void HandleFailedNavigationForTrackedLoad( 120 void HandleFailedNavigationForTrackedLoad(
107 content::NavigationHandle* navigation_handle, 121 content::NavigationHandle* navigation_handle,
108 std::unique_ptr<PageLoadTracker> tracker); 122 std::unique_ptr<PageLoadTracker> tracker);
109 123
110 void HandleCommittedNavigationForTrackedLoad( 124 void HandleCommittedNavigationForTrackedLoad(
111 content::NavigationHandle* navigation_handle, 125 content::NavigationHandle* navigation_handle,
112 std::unique_ptr<PageLoadTracker> tracker); 126 std::unique_ptr<PageLoadTracker> tracker);
113 127
114 // Return a PageLoadTracker (either provisional or committed) that matches the 128 // Return a PageLoadTracker (either provisional or committed) that matches the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // navigation failed. This is because most provisional loads are destroyed 180 // navigation failed. This is because most provisional loads are destroyed
167 // and vanish before we get signal about what caused the abort (new 181 // and vanish before we get signal about what caused the abort (new
168 // navigation, stop button, etc.). 182 // navigation, stop button, etc.).
169 std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_; 183 std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_;
170 184
171 std::unique_ptr<PageLoadTracker> committed_load_; 185 std::unique_ptr<PageLoadTracker> committed_load_;
172 186
173 // Has the MWCO observed at least one navigation? 187 // Has the MWCO observed at least one navigation?
174 bool has_navigated_; 188 bool has_navigated_;
175 189
190 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics>
191 page_load_metrics_binding_;
192
176 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 193 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
177 }; 194 };
178 195
179 } // namespace page_load_metrics 196 } // namespace page_load_metrics
180 197
181 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 198 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698