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

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 unit test for page_load_metrics_struct_traits Created 3 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
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/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" 15 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
16 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h"
16 #include "chrome/common/page_load_metrics/page_load_timing.h" 17 #include "chrome/common/page_load_metrics/page_load_timing.h"
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h"
18 #include "content/public/browser/render_widget_host.h" 19 #include "content/public/browser/render_widget_host.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_binding_set.h"
20 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_contents_user_data.h" 23 #include "content/public/browser/web_contents_user_data.h"
22 #include "content/public/common/resource_type.h" 24 #include "content/public/common/resource_type.h"
25 #include "mojo/public/cpp/bindings/binding_set.h"
23 #include "third_party/WebKit/public/platform/WebInputEvent.h" 26 #include "third_party/WebKit/public/platform/WebInputEvent.h"
24 27
25 namespace content { 28 namespace content {
26 class NavigationHandle; 29 class NavigationHandle;
27 class RenderFrameHost; 30 class RenderFrameHost;
28 } // namespace content 31 } // namespace content
29 32
30 namespace IPC { 33 namespace IPC {
31 class Message; 34 class Message;
32 } // namespace IPC 35 } // namespace IPC
33 36
34 namespace page_load_metrics { 37 namespace page_load_metrics {
35 38
36 class PageLoadMetricsEmbedderInterface; 39 class PageLoadMetricsEmbedderInterface;
37 class PageLoadTracker; 40 class PageLoadTracker;
38 41
39 // MetricsWebContentsObserver tracks page loads and loading metrics 42 // MetricsWebContentsObserver tracks page loads and loading metrics
40 // related data based on IPC messages received from a 43 // related data based on IPC messages received from a
41 // MetricsRenderFrameObserver. 44 // MetricsRenderFrameObserver.
42 class MetricsWebContentsObserver 45 class MetricsWebContentsObserver
43 : public content::WebContentsObserver, 46 : public content::WebContentsObserver,
44 public content::WebContentsUserData<MetricsWebContentsObserver>, 47 public content::WebContentsUserData<MetricsWebContentsObserver>,
45 public content::RenderWidgetHost::InputEventObserver { 48 public content::RenderWidgetHost::InputEventObserver,
49 public mojom::PageLoadMetrics {
46 public: 50 public:
47 // TestingObserver allows tests to observe MetricsWebContentsObserver state 51 // TestingObserver allows tests to observe MetricsWebContentsObserver state
48 // changes. Tests may use TestingObserver to wait until certain state changes, 52 // changes. Tests may use TestingObserver to wait until certain state changes,
49 // such as the arrivial of PageLoadTiming messages from the render process, 53 // such as the arrivial of PageLoadTiming messages from the render process,
50 // have been observed. 54 // have been observed.
51 class TestingObserver { 55 class TestingObserver {
52 public: 56 public:
53 explicit TestingObserver(content::WebContents* web_contents); 57 explicit TestingObserver(content::WebContents* web_contents);
54 virtual ~TestingObserver(); 58 virtual ~TestingObserver();
55 59
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 139
136 // Register / unregister TestingObservers. Should only be called from tests. 140 // Register / unregister TestingObservers. Should only be called from tests.
137 void AddTestingObserver(TestingObserver* observer); 141 void AddTestingObserver(TestingObserver* observer);
138 void RemoveTestingObserver(TestingObserver* observer); 142 void RemoveTestingObserver(TestingObserver* observer);
139 143
140 // public only for testing 144 // public only for testing
141 void OnTimingUpdated(content::RenderFrameHost* render_frame_host, 145 void OnTimingUpdated(content::RenderFrameHost* render_frame_host,
142 const PageLoadTiming& timing, 146 const PageLoadTiming& timing,
143 const PageLoadMetadata& metadata); 147 const PageLoadMetadata& metadata);
144 148
149 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics>&
150 page_load_metrics_binding_for_testing() {
Bryan McQuade 2017/05/07 19:44:41 looks like this is no longer used. remove?
lpy 2017/05/08 18:38:33 Done.
151 return page_load_metrics_binding_;
152 }
153
145 private: 154 private:
146 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 155 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
156 friend class FakePageLoadMetrics;
Bryan McQuade 2017/05/07 19:44:41 can remove - this class doesn't appear to exist an
lpy 2017/05/08 18:38:33 Done.
157 friend class MetricsWebContentsObserverTest;
Bryan McQuade 2017/05/07 19:44:41 can remove - don't need friend anymore
lpy 2017/05/08 18:38:33 Done.
158 friend class PageLoadMetricsObserverTestHarness;
Bryan McQuade 2017/05/07 19:44:41 can remove - don't need friend anymore
lpy 2017/05/08 18:38:33 Done.
159
160 // page_load_metrics::mojom::PageLoadMetrics implementation.
161 void UpdateTiming(const PageLoadTiming& timing,
162 const PageLoadMetadata& metadata) override;
147 163
148 void HandleFailedNavigationForTrackedLoad( 164 void HandleFailedNavigationForTrackedLoad(
149 content::NavigationHandle* navigation_handle, 165 content::NavigationHandle* navigation_handle,
150 std::unique_ptr<PageLoadTracker> tracker); 166 std::unique_ptr<PageLoadTracker> tracker);
151 167
152 void HandleCommittedNavigationForTrackedLoad( 168 void HandleCommittedNavigationForTrackedLoad(
153 content::NavigationHandle* navigation_handle, 169 content::NavigationHandle* navigation_handle,
154 std::unique_ptr<PageLoadTracker> tracker); 170 std::unique_ptr<PageLoadTracker> tracker);
155 171
156 // Return a PageLoadTracker (either provisional or committed) that matches the 172 // Return a PageLoadTracker (either provisional or committed) that matches the
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // and vanish before we get signal about what caused the abort (new 221 // and vanish before we get signal about what caused the abort (new
206 // navigation, stop button, etc.). 222 // navigation, stop button, etc.).
207 std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_; 223 std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_;
208 224
209 std::unique_ptr<PageLoadTracker> committed_load_; 225 std::unique_ptr<PageLoadTracker> committed_load_;
210 226
211 // Has the MWCO observed at least one navigation? 227 // Has the MWCO observed at least one navigation?
212 bool has_navigated_; 228 bool has_navigated_;
213 229
214 base::ObserverList<TestingObserver> testing_observers_; 230 base::ObserverList<TestingObserver> testing_observers_;
231 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics>
232 page_load_metrics_binding_;
215 233
216 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 234 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
217 }; 235 };
218 236
219 } // namespace page_load_metrics 237 } // namespace page_load_metrics
220 238
221 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 239 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698