OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // have been observed. | 50 // have been observed. |
51 class TestingObserver { | 51 class TestingObserver { |
52 public: | 52 public: |
53 explicit TestingObserver(content::WebContents* web_contents); | 53 explicit TestingObserver(content::WebContents* web_contents); |
54 virtual ~TestingObserver(); | 54 virtual ~TestingObserver(); |
55 | 55 |
56 void OnGoingAway(); | 56 void OnGoingAway(); |
57 | 57 |
58 // Invoked when a new PageLoadTiming update has been received and processed. | 58 // Invoked when a new PageLoadTiming update has been received and processed. |
59 virtual void OnTimingUpdated(bool is_main_frame, | 59 virtual void OnTimingUpdated(bool is_main_frame, |
60 const PageLoadTiming& timing, | 60 const mojom::PageLoadTiming& timing, |
61 const PageLoadMetadata& metadata) {} | 61 const mojom::PageLoadMetadata& metadata) {} |
62 | 62 |
63 private: | 63 private: |
64 page_load_metrics::MetricsWebContentsObserver* observer_; | 64 page_load_metrics::MetricsWebContentsObserver* observer_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(TestingObserver); | 66 DISALLOW_COPY_AND_ASSIGN(TestingObserver); |
67 }; | 67 }; |
68 | 68 |
69 // Note that the returned metrics is owned by the web contents. | 69 // Note that the returned metrics is owned by the web contents. |
70 static MetricsWebContentsObserver* CreateForWebContents( | 70 static MetricsWebContentsObserver* CreateForWebContents( |
71 content::WebContents* web_contents, | 71 content::WebContents* web_contents, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 // This getter function is required for testing. | 134 // This getter function is required for testing. |
135 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); | 135 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); |
136 | 136 |
137 // Register / unregister TestingObservers. Should only be called from tests. | 137 // Register / unregister TestingObservers. Should only be called from tests. |
138 void AddTestingObserver(TestingObserver* observer); | 138 void AddTestingObserver(TestingObserver* observer); |
139 void RemoveTestingObserver(TestingObserver* observer); | 139 void RemoveTestingObserver(TestingObserver* observer); |
140 | 140 |
141 // public only for testing | 141 // public only for testing |
142 void OnTimingUpdated(content::RenderFrameHost* render_frame_host, | 142 void OnTimingUpdated(content::RenderFrameHost* render_frame_host, |
143 const PageLoadTiming& timing, | 143 const mojom::PageLoadTiming& timing, |
144 const PageLoadMetadata& metadata); | 144 const mojom::PageLoadMetadata& metadata); |
145 | 145 |
146 private: | 146 private: |
147 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 147 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
148 | 148 |
149 void HandleFailedNavigationForTrackedLoad( | 149 void HandleFailedNavigationForTrackedLoad( |
150 content::NavigationHandle* navigation_handle, | 150 content::NavigationHandle* navigation_handle, |
151 std::unique_ptr<PageLoadTracker> tracker); | 151 std::unique_ptr<PageLoadTracker> tracker); |
152 | 152 |
153 void HandleCommittedNavigationForTrackedLoad( | 153 void HandleCommittedNavigationForTrackedLoad( |
154 content::NavigationHandle* navigation_handle, | 154 content::NavigationHandle* navigation_handle, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 bool has_navigated_; | 213 bool has_navigated_; |
214 | 214 |
215 base::ObserverList<TestingObserver> testing_observers_; | 215 base::ObserverList<TestingObserver> testing_observers_; |
216 | 216 |
217 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 217 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
218 }; | 218 }; |
219 | 219 |
220 } // namespace page_load_metrics | 220 } // namespace page_load_metrics |
221 | 221 |
222 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ | 222 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |