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

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

Issue 2948323002: [PageLoadMetrics] Remove legacy IPC from Page Load Metrics. (Closed)
Patch Set: Created 3 years, 6 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>
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
23 #include "content/public/browser/web_contents_user_data.h" 23 #include "content/public/browser/web_contents_user_data.h"
24 #include "content/public/common/resource_type.h" 24 #include "content/public/common/resource_type.h"
25 #include "third_party/WebKit/public/platform/WebInputEvent.h" 25 #include "third_party/WebKit/public/platform/WebInputEvent.h"
26 26
27 namespace content { 27 namespace content {
28 class NavigationHandle; 28 class NavigationHandle;
29 class RenderFrameHost; 29 class RenderFrameHost;
30 } // namespace content 30 } // namespace content
31 31
32 namespace IPC {
33 class Message;
34 } // namespace IPC
35
36 namespace page_load_metrics { 32 namespace page_load_metrics {
37 33
38 class PageLoadMetricsEmbedderInterface; 34 class PageLoadMetricsEmbedderInterface;
39 class PageLoadTracker; 35 class PageLoadTracker;
40 36
41 // MetricsWebContentsObserver tracks page loads and loading metrics 37 // MetricsWebContentsObserver tracks page loads and loading metrics
42 // related data based on IPC messages received from a 38 // related data based on IPC messages received from a
43 // MetricsRenderFrameObserver. 39 // MetricsRenderFrameObserver.
44 class MetricsWebContentsObserver 40 class MetricsWebContentsObserver
45 : public content::WebContentsObserver, 41 : public content::WebContentsObserver,
46 public content::WebContentsUserData<MetricsWebContentsObserver>, 42 public content::WebContentsUserData<MetricsWebContentsObserver>,
47 public content::RenderWidgetHost::InputEventObserver, 43 public content::RenderWidgetHost::InputEventObserver,
48 public mojom::PageLoadMetrics { 44 public mojom::PageLoadMetrics {
49 public: 45 public:
50 // TestingObserver allows tests to observe MetricsWebContentsObserver state 46 // TestingObserver allows tests to observe MetricsWebContentsObserver state
51 // changes. Tests may use TestingObserver to wait until certain state changes, 47 // changes. Tests may use TestingObserver to wait until certain state changes,
52 // such as the arrivial of PageLoadTiming messages from the render process, 48 // such as the arrivial of PageLoadTiming messages from the render process,
53 // have been observed. 49 // have been observed.
54 class TestingObserver { 50 class TestingObserver {
55 public: 51 public:
56 enum class IPCType { LEGACY, MOJO };
57
58 explicit TestingObserver(content::WebContents* web_contents); 52 explicit TestingObserver(content::WebContents* web_contents);
59 virtual ~TestingObserver(); 53 virtual ~TestingObserver();
60 54
61 void OnGoingAway(); 55 void OnGoingAway();
62 56
63 virtual void OnCommit(PageLoadTracker* tracker) {} 57 virtual void OnCommit(PageLoadTracker* tracker) {}
64 virtual void DidReceiveTimingUpdate(IPCType type) {} 58 virtual void DidReceiveTimingUpdate() {}
Bryan McQuade 2017/06/23 15:15:07 this callback was actually only really for verifyi
lpy 2017/06/23 21:23:46 Done.
65 59
66 private: 60 private:
67 page_load_metrics::MetricsWebContentsObserver* observer_; 61 page_load_metrics::MetricsWebContentsObserver* observer_;
68 62
69 DISALLOW_COPY_AND_ASSIGN(TestingObserver); 63 DISALLOW_COPY_AND_ASSIGN(TestingObserver);
70 }; 64 };
71 65
72 // Note that the returned metrics is owned by the web contents. 66 // Note that the returned metrics is owned by the web contents.
73 static MetricsWebContentsObserver* CreateForWebContents( 67 static MetricsWebContentsObserver* CreateForWebContents(
74 content::WebContents* web_contents, 68 content::WebContents* web_contents,
75 const base::Optional<content::WebContents::CreateParams>& create_params, 69 const base::Optional<content::WebContents::CreateParams>& create_params,
76 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 70 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
77 MetricsWebContentsObserver( 71 MetricsWebContentsObserver(
78 content::WebContents* web_contents, 72 content::WebContents* web_contents,
79 const base::Optional<content::WebContents::CreateParams>& create_params, 73 const base::Optional<content::WebContents::CreateParams>& create_params,
80 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 74 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
81 ~MetricsWebContentsObserver() override; 75 ~MetricsWebContentsObserver() override;
82 76
83 // content::WebContentsObserver implementation: 77 // content::WebContentsObserver implementation:
84 bool OnMessageReceived(const IPC::Message& message,
85 content::RenderFrameHost* render_frame_host) override;
86 void DidFinishNavigation( 78 void DidFinishNavigation(
87 content::NavigationHandle* navigation_handle) override; 79 content::NavigationHandle* navigation_handle) override;
88 void DidRedirectNavigation( 80 void DidRedirectNavigation(
89 content::NavigationHandle* navigation_handle) override; 81 content::NavigationHandle* navigation_handle) override;
90 void NavigationStopped() override; 82 void NavigationStopped() override;
91 void OnInputEvent(const blink::WebInputEvent& event) override; 83 void OnInputEvent(const blink::WebInputEvent& event) override;
92 void WasShown() override; 84 void WasShown() override;
93 void WasHidden() override; 85 void WasHidden() override;
94 void RenderProcessGone(base::TerminationStatus status) override; 86 void RenderProcessGone(base::TerminationStatus status) override;
95 void RenderViewHostChanged(content::RenderViewHost* old_host, 87 void RenderViewHostChanged(content::RenderViewHost* old_host,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const mojom::PageLoadTiming& timing, 137 const mojom::PageLoadTiming& timing,
146 const mojom::PageLoadMetadata& metadata); 138 const mojom::PageLoadMetadata& metadata);
147 139
148 private: 140 private:
149 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 141 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
150 142
151 // page_load_metrics::mojom::PageLoadMetrics implementation. 143 // page_load_metrics::mojom::PageLoadMetrics implementation.
152 void UpdateTiming(mojom::PageLoadTimingPtr timing, 144 void UpdateTiming(mojom::PageLoadTimingPtr timing,
153 mojom::PageLoadMetadataPtr metadata) override; 145 mojom::PageLoadMetadataPtr metadata) override;
154 146
155 // Called from legacy IPC.
156 void OnUpdateTimingOverIPC(content::RenderFrameHost* render_frame_host,
157 const mojom::PageLoadTiming& timing,
158 const mojom::PageLoadMetadata& metadata);
159
160 void HandleFailedNavigationForTrackedLoad( 147 void HandleFailedNavigationForTrackedLoad(
161 content::NavigationHandle* navigation_handle, 148 content::NavigationHandle* navigation_handle,
162 std::unique_ptr<PageLoadTracker> tracker); 149 std::unique_ptr<PageLoadTracker> tracker);
163 150
164 void HandleCommittedNavigationForTrackedLoad( 151 void HandleCommittedNavigationForTrackedLoad(
165 content::NavigationHandle* navigation_handle, 152 content::NavigationHandle* navigation_handle,
166 std::unique_ptr<PageLoadTracker> tracker); 153 std::unique_ptr<PageLoadTracker> tracker);
167 154
168 // Return a PageLoadTracker (either provisional or committed) that matches the 155 // Return a PageLoadTracker (either provisional or committed) that matches the
169 // given request attributes, or nullptr if there are no matching 156 // given request attributes, or nullptr if there are no matching
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 base::ObserverList<TestingObserver> testing_observers_; 213 base::ObserverList<TestingObserver> testing_observers_;
227 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics> 214 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics>
228 page_load_metrics_binding_; 215 page_load_metrics_binding_;
229 216
230 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 217 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
231 }; 218 };
232 219
233 } // namespace page_load_metrics 220 } // namespace page_load_metrics
234 221
235 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 222 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698