Chromium Code Reviews| Index: chrome/browser/page_load_metrics/observers/previews_ukm_observer.h |
| diff --git a/chrome/browser/page_load_metrics/observers/previews_ukm_observer.h b/chrome/browser/page_load_metrics/observers/previews_ukm_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b25a515fd201fda103c25a01cd43d376a9aa3d8b |
| --- /dev/null |
| +++ b/chrome/browser/page_load_metrics/observers/previews_ukm_observer.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2017 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 CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PREVIEWS_UKM_OBSERVER_H_ |
| +#define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PREVIEWS_UKM_OBSERVER_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
| + |
| +namespace content { |
| +class NavigationHandle; |
| +} |
| + |
| +namespace previews { |
| + |
| +// This enum should never be re-ordered to keep a consistent set of previews |
| +// when reading logs. |
| +enum PreviewsUKMValues { |
|
rkaplow
2017/06/27 22:17:09
it's not clear to me why you want to encode this i
RyanSturm
2017/06/28 16:19:35
That approach is what I initially proposed, since
Bryan McQuade
2017/06/28 16:48:18
Yes, I'm totally supportive of switching to separa
RyanSturm
2017/07/11 21:46:40
Done.
|
| + PREVIEWS_UKM_NONE = 0, |
| + PREVIEWS_UKM_CLIENT_LOFI = 1, |
| + PREVIEWS_UKM_SERVER_LOFI = 1 << 1, |
| + PREVIEWS_UKM_LITE_PAGE = 1 << 2, |
| +}; |
| + |
| +// Observer responsible for appending previews information to the PLM UKM |
| +// report. |
| +class PreviewsUKMObserver : public page_load_metrics::PageLoadMetricsObserver { |
| + public: |
| + PreviewsUKMObserver(); |
| + ~PreviewsUKMObserver() override; |
| + |
| + // page_load_metrics::PageLoadMetricsObserver: |
| + ObservePolicy OnStart(content::NavigationHandle* navigation_handle, |
| + const GURL& currently_committed_url, |
| + bool started_in_foreground) override; |
| + ObservePolicy OnCommit(content::NavigationHandle* navigation_handle, |
| + ukm::SourceId source_id) override; |
| + ObservePolicy FlushMetricsOnAppEnterBackground( |
| + const page_load_metrics::mojom::PageLoadTiming& timing, |
| + const page_load_metrics::PageLoadExtraInfo& info) override; |
| + void OnComplete(const page_load_metrics::mojom::PageLoadTiming& timing, |
| + const page_load_metrics::PageLoadExtraInfo& info) override; |
| + void OnLoadedResource(const page_load_metrics::ExtraRequestCompleteInfo& |
| + extra_request_complete_info) override; |
| + |
| + private: |
| + void RecordPreviewsTypes(const page_load_metrics::PageLoadExtraInfo& info); |
| + |
| + int previews_types_ = PREVIEWS_UKM_NONE; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PreviewsUKMObserver); |
| +}; |
| + |
| +} // namespace previews |
| + |
| +#endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PREVIEWS_UKM_OBSERVER_H_ |