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

Side by Side Diff: chrome/browser/page_load_metrics/observers/subresource_filter_metrics_observer.h

Issue 2893183002: [subresource_filter] Use the SubresourceFilterObserver for PageLoadMetrics (Closed)
Patch Set: bmcquade review 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_OBSERVERS_SUBRESOURCE_FILTER_METRICS_OB SERVER_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_SUBRESOURCE_FILTER_METRICS_OB SERVER_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_SUBRESOURCE_FILTER_METRICS_OB SERVER_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_SUBRESOURCE_FILTER_METRICS_OB SERVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/optional.h"
10 #include "base/scoped_observer.h"
9 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" 11 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
12 #include "components/subresource_filter/content/browser/subresource_filter_obser ver.h"
13 #include "components/subresource_filter/content/browser/subresource_filter_obser ver_manager.h"
10 #include "components/ukm/ukm_source.h" 14 #include "components/ukm/ukm_source.h"
11 15
12 namespace internal { 16 namespace internal {
13 17
14 extern const char kHistogramSubresourceFilterFirstContentfulPaint[]; 18 extern const char kHistogramSubresourceFilterFirstContentfulPaint[];
15 extern const char kHistogramSubresourceFilterParseStartToFirstContentfulPaint[]; 19 extern const char kHistogramSubresourceFilterParseStartToFirstContentfulPaint[];
16 extern const char kHistogramSubresourceFilterFirstMeaningfulPaint[]; 20 extern const char kHistogramSubresourceFilterFirstMeaningfulPaint[];
17 extern const char kHistogramSubresourceFilterParseStartToFirstMeaningfulPaint[]; 21 extern const char kHistogramSubresourceFilterParseStartToFirstMeaningfulPaint[];
18 22
19 extern const char kHistogramSubresourceFilterTotalResources[]; 23 extern const char kHistogramSubresourceFilterTotalResources[];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 extern const char kHistogramSubresourceFilterForegroundDurationAfterPaint[]; 56 extern const char kHistogramSubresourceFilterForegroundDurationAfterPaint[];
53 57
54 extern const char kHistogramSubresourceFilterCount[]; 58 extern const char kHistogramSubresourceFilterCount[];
55 59
56 extern const char kHistogramSubresourceFilterActivationDecision[]; 60 extern const char kHistogramSubresourceFilterActivationDecision[];
57 extern const char kHistogramSubresourceFilterActivationDecisionReload[]; 61 extern const char kHistogramSubresourceFilterActivationDecisionReload[];
58 62
59 } // namespace internal 63 } // namespace internal
60 64
61 class SubresourceFilterMetricsObserver 65 class SubresourceFilterMetricsObserver
62 : public page_load_metrics::PageLoadMetricsObserver { 66 : public page_load_metrics::PageLoadMetricsObserver,
67 public subresource_filter::SubresourceFilterObserver {
63 public: 68 public:
64 SubresourceFilterMetricsObserver() = default; 69 SubresourceFilterMetricsObserver();
65 ~SubresourceFilterMetricsObserver() override = default; 70 ~SubresourceFilterMetricsObserver() override;
66 71
67 // page_load_metrics::PageLoadMetricsObserver: 72 // page_load_metrics::PageLoadMetricsObserver:
73 ObservePolicy OnStart(content::NavigationHandle* navigation_handle,
74 const GURL& currently_committed_url,
75 bool started_in_foreground) override;
68 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle, 76 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle,
69 ukm::SourceId source_id) override; 77 ukm::SourceId source_id) override;
70 ObservePolicy FlushMetricsOnAppEnterBackground( 78 ObservePolicy FlushMetricsOnAppEnterBackground(
71 const page_load_metrics::mojom::PageLoadTiming& timing, 79 const page_load_metrics::mojom::PageLoadTiming& timing,
72 const page_load_metrics::PageLoadExtraInfo& info) override; 80 const page_load_metrics::PageLoadExtraInfo& info) override;
73 void OnComplete(const page_load_metrics::mojom::PageLoadTiming& timing, 81 void OnComplete(const page_load_metrics::mojom::PageLoadTiming& timing,
74 const page_load_metrics::PageLoadExtraInfo& info) override; 82 const page_load_metrics::PageLoadExtraInfo& info) override;
75 void OnLoadedResource(const page_load_metrics::ExtraRequestCompleteInfo& 83 void OnLoadedResource(const page_load_metrics::ExtraRequestCompleteInfo&
76 extra_request_complete_info) override; 84 extra_request_complete_info) override;
77 void OnParseStop(const page_load_metrics::mojom::PageLoadTiming& timing, 85 void OnParseStop(const page_load_metrics::mojom::PageLoadTiming& timing,
(...skipping 10 matching lines...) Expand all
88 void OnLoadEventStart( 96 void OnLoadEventStart(
89 const page_load_metrics::mojom::PageLoadTiming& timing, 97 const page_load_metrics::mojom::PageLoadTiming& timing,
90 const page_load_metrics::PageLoadExtraInfo& extra_info) override; 98 const page_load_metrics::PageLoadExtraInfo& extra_info) override;
91 void OnLoadingBehaviorObserved( 99 void OnLoadingBehaviorObserved(
92 const page_load_metrics::PageLoadExtraInfo& extra_info) override; 100 const page_load_metrics::PageLoadExtraInfo& extra_info) override;
93 void MediaStartedPlaying( 101 void MediaStartedPlaying(
94 const content::WebContentsObserver::MediaPlayerInfo& video_type, 102 const content::WebContentsObserver::MediaPlayerInfo& video_type,
95 bool is_in_main_frame) override; 103 bool is_in_main_frame) override;
96 104
97 private: 105 private:
106 // subresource_filter::SubresourceFilterObserver:
107 void OnSubresourceFilterGoingAway() override;
108 void OnPageActivationComputed(
109 content::NavigationHandle* navigation_handle,
110 subresource_filter::ActivationDecision activation_decision,
111 const subresource_filter::ActivationState& activation_state) override;
112
98 void OnGoingAway(const page_load_metrics::mojom::PageLoadTiming& timing, 113 void OnGoingAway(const page_load_metrics::mojom::PageLoadTiming& timing,
99 const page_load_metrics::PageLoadExtraInfo& info, 114 const page_load_metrics::PageLoadExtraInfo& info,
100 base::TimeTicks app_background_time); 115 base::TimeTicks app_background_time);
101 116
117 base::Optional<subresource_filter::ActivationDecision> activation_decision_;
118
119 ScopedObserver<subresource_filter::SubresourceFilterObserverManager,
120 subresource_filter::SubresourceFilterObserver>
121 scoped_observer_;
122
102 int64_t network_bytes_ = 0; 123 int64_t network_bytes_ = 0;
103 int64_t cache_bytes_ = 0; 124 int64_t cache_bytes_ = 0;
104 125
105 int num_network_resources_ = 0; 126 int num_network_resources_ = 0;
106 int num_cache_resources_ = 0; 127 int num_cache_resources_ = 0;
107 128
129 // Used as a unique id for the ongoing navigation. Do not use after OnCommit.
130 content::NavigationHandle* navigation_handle_ = nullptr;
131
108 bool subresource_filter_observed_ = false; 132 bool subresource_filter_observed_ = false;
109 bool played_media_ = false; 133 bool played_media_ = false;
134 bool did_commit_ = false;
110 135
111 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterMetricsObserver); 136 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterMetricsObserver);
112 }; 137 };
113 138
114 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_SUBRESOURCE_FILTER_METRICS _OBSERVER_H_ 139 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_SUBRESOURCE_FILTER_METRICS _OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698