| // Copyright 2020 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef WEBLAYER_BROWSER_UKM_PAGE_LOAD_METRICS_OBSERVER_H_ |
| #define WEBLAYER_BROWSER_UKM_PAGE_LOAD_METRICS_OBSERVER_H_ |
| |
| #include "components/page_load_metrics/browser/page_load_metrics_observer.h" |
| |
| namespace content { |
| class NavigationHandle; |
| } |
| |
| namespace weblayer { |
| |
| // If URL-Keyed-Metrics (UKM) is enabled in the system, this is used to |
| // populate it with top-level page-load metrics. |
| class UkmPageLoadMetricsObserver |
| : public page_load_metrics::PageLoadMetricsObserver { |
| public: |
| // Returns a UkmPageLoadMetricsObserver, or nullptr if it is not needed. |
| static std::unique_ptr<page_load_metrics::PageLoadMetricsObserver> |
| CreateIfNeeded(); |
| |
| UkmPageLoadMetricsObserver() = default; |
| ~UkmPageLoadMetricsObserver() override = default; |
| |
| // page_load_metrics::PageLoadMetricsObserver implementation: |
| ObservePolicy OnCommit(content::NavigationHandle* navigation_handle, |
| ukm::SourceId source_id) override; |
| }; |
| |
| } // namespace weblayer |
| |
| #endif // WEBLAYER_BROWSER_UKM_PAGE_LOAD_METRICS_OBSERVER_H_ |