| 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> |
| 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/optional.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" | 16 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
| 16 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h" | 17 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h" |
| 17 #include "chrome/common/page_load_metrics/page_load_timing.h" | 18 #include "chrome/common/page_load_metrics/page_load_timing.h" |
| 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
| 20 #include "components/ukm/ukm_source.h" |
| 19 #include "content/public/browser/render_widget_host.h" | 21 #include "content/public/browser/render_widget_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_binding_set.h" | 23 #include "content/public/browser/web_contents_binding_set.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "content/public/browser/web_contents_user_data.h" | 25 #include "content/public/browser/web_contents_user_data.h" |
| 24 #include "content/public/common/resource_type.h" | 26 #include "content/public/common/resource_type.h" |
| 25 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 27 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 26 | 28 |
| 27 namespace content { | 29 namespace content { |
| 28 class NavigationHandle; | 30 class NavigationHandle; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 140 |
| 139 // Register / unregister TestingObservers. Should only be called from tests. | 141 // Register / unregister TestingObservers. Should only be called from tests. |
| 140 void AddTestingObserver(TestingObserver* observer); | 142 void AddTestingObserver(TestingObserver* observer); |
| 141 void RemoveTestingObserver(TestingObserver* observer); | 143 void RemoveTestingObserver(TestingObserver* observer); |
| 142 | 144 |
| 143 // public only for testing | 145 // public only for testing |
| 144 void OnTimingUpdated(content::RenderFrameHost* render_frame_host, | 146 void OnTimingUpdated(content::RenderFrameHost* render_frame_host, |
| 145 const mojom::PageLoadTiming& timing, | 147 const mojom::PageLoadTiming& timing, |
| 146 const mojom::PageLoadMetadata& metadata); | 148 const mojom::PageLoadMetadata& metadata); |
| 147 | 149 |
| 150 // Gets the Source ID for the load related to |navigation_handle| if it is |
| 151 // pending, can be empty if the load is not pending. |
| 152 base::Optional<ukm::SourceId> GetUKMSourceIdForNavigationHandle( |
| 153 content::NavigationHandle* navigation_handle); |
| 154 |
| 155 // Gets the Source ID for the currently committed load if there is a committed |
| 156 // load. |
| 157 base::Optional<ukm::SourceId> GetUKMSourceForCommittedLoad(); |
| 158 |
| 148 private: | 159 private: |
| 149 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 160 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
| 150 | 161 |
| 151 // page_load_metrics::mojom::PageLoadMetrics implementation. | 162 // page_load_metrics::mojom::PageLoadMetrics implementation. |
| 152 void UpdateTiming(mojom::PageLoadTimingPtr timing, | 163 void UpdateTiming(mojom::PageLoadTimingPtr timing, |
| 153 mojom::PageLoadMetadataPtr metadata) override; | 164 mojom::PageLoadMetadataPtr metadata) override; |
| 154 | 165 |
| 155 // Called from legacy IPC. | 166 // Called from legacy IPC. |
| 156 void OnUpdateTimingOverIPC(content::RenderFrameHost* render_frame_host, | 167 void OnUpdateTimingOverIPC(content::RenderFrameHost* render_frame_host, |
| 157 const mojom::PageLoadTiming& timing, | 168 const mojom::PageLoadTiming& timing, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 base::ObserverList<TestingObserver> testing_observers_; | 237 base::ObserverList<TestingObserver> testing_observers_; |
| 227 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics> | 238 content::WebContentsFrameBindingSet<mojom::PageLoadMetrics> |
| 228 page_load_metrics_binding_; | 239 page_load_metrics_binding_; |
| 229 | 240 |
| 230 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 241 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 231 }; | 242 }; |
| 232 | 243 |
| 233 } // namespace page_load_metrics | 244 } // namespace page_load_metrics |
| 234 | 245 |
| 235 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ | 246 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |