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

Side by Side Diff: components/page_load_metrics/browser/metrics_web_contents_observer.h

Issue 1837233002: Optional <TimeDelta> since they may be non existent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, Fixed non-deterministic tests and Bryan's review comments. Created 4 years, 7 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 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 COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // cc file for details). We use this error counter to understand how often it 80 // cc file for details). We use this error counter to understand how often it
81 // happens. 81 // happens.
82 ERR_ABORT_BEFORE_NAVIGATION_START, 82 ERR_ABORT_BEFORE_NAVIGATION_START,
83 83
84 // A new navigation triggers abort updates in multiple trackers in 84 // A new navigation triggers abort updates in multiple trackers in
85 // |aborted_provisional_loads_|, when usually there should only be one (the 85 // |aborted_provisional_loads_|, when usually there should only be one (the
86 // navigation that just aborted because of this one). If this happens, the 86 // navigation that just aborted because of this one). If this happens, the
87 // latest aborted load is used to track the chain size. 87 // latest aborted load is used to track the chain size.
88 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, 88 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS,
89 89
90 // A timetick in the browser process has value lesser than navigation_start_.
Charlie Harrison 2016/05/19 18:20:49 nit: A TimeTicks value in the browser process has
shivanisha 2016/05/23 15:06:43 done
91 // This could happen if the navigation_start_ was computed in the renderer
92 // process and the system clock has inter process time tick skew.
93 ERR_INTER_PROCESS_TIME_TICK_SKEW,
94
90 // Add values before this final count. 95 // Add values before this final count.
91 ERR_LAST_ENTRY 96 ERR_LAST_ENTRY
92 }; 97 };
93 98
94 // This class serves as a functional interface to various chrome// features. 99 // This class serves as a functional interface to various chrome// features.
95 // Impl version is defined in chrome/browser/page_load_metrics. 100 // Impl version is defined in chrome/browser/page_load_metrics.
96 class PageLoadMetricsEmbedderInterface { 101 class PageLoadMetricsEmbedderInterface {
97 public: 102 public:
98 virtual ~PageLoadMetricsEmbedderInterface() {} 103 virtual ~PageLoadMetricsEmbedderInterface() {}
99 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; 104 virtual bool IsPrerendering(content::WebContents* web_contents) = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 141 }
137 142
138 UserAbortType abort_type() const { return abort_type_; } 143 UserAbortType abort_type() const { return abort_type_; }
139 base::TimeTicks abort_time() const { return abort_time_; } 144 base::TimeTicks abort_time() const { return abort_time_; }
140 145
141 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); 146 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer);
142 147
143 // If the user performs some abort-like action while we are tracking this page 148 // If the user performs some abort-like action while we are tracking this page
144 // load, notify the tracker. Note that we may not classify this as an abort if 149 // load, notify the tracker. Note that we may not classify this as an abort if
145 // we've already performed a first paint. 150 // we've already performed a first paint.
146 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp); 151 void NotifyAbort(UserAbortType abort_type,
147 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp); 152 base::TimeTicks timestamp,
153 bool is_browser_timetick);
Charlie Harrison 2016/05/19 18:20:49 Let's replace "timetick" with "timestamp". Also in
shivanisha 2016/05/23 15:06:43 done
154 void UpdateAbort(UserAbortType abort_type,
155 base::TimeTicks timestamp,
156 bool is_browser_timetick);
148 157
149 // This method returns true if this page load has been aborted with type of 158 // This method returns true if this page load has been aborted with type of
150 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 159 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close
151 // delta to when it was aborted. Note that only provisional loads can be 160 // delta to when it was aborted. Note that only provisional loads can be
152 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 161 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better
153 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 162 // and is simpler than other feasible methods. See https://goo.gl/WKRG98.
154 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); 163 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time);
155 164
156 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); 165 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle);
157 166
158 // Only valid to call post-commit. 167 // Only valid to call post-commit.
159 const GURL& committed_url() const { 168 const GURL& committed_url() const {
160 DCHECK(!commit_time_.is_null()); 169 DCHECK(!commit_time_.is_null());
161 return url_; 170 return url_;
162 } 171 }
163 172
173 PageLoadExtraInfo ComputePageLoadExtraInfo();
174
164 private: 175 private:
165 PageLoadExtraInfo GetPageLoadMetricsInfo(); 176 // This function converts a TimeTicks value taken in the browser process
177 // to navigation_start_ if:
178 // - base::TimeTicks is not comparable across processes because the clock
179 // is not system wide monotonic.
180 // - *event_time < navigation_start_
181 void ClampBrowserTimestampIfInterProcessTimeTickSkew(
182 base::TimeTicks* event_time);
166 183
167 void UpdateAbortInternal(UserAbortType abort_type, 184 void UpdateAbortInternal(UserAbortType abort_type,
168 base::TimeTicks timestamp); 185 base::TimeTicks timestamp,
186 bool is_browser_timetick);
169 187
170 // If |final_navigation| is null, then this is an "unparented" abort chain, 188 // If |final_navigation| is null, then this is an "unparented" abort chain,
171 // and represents a sequence of provisional aborts that never ends with a 189 // and represents a sequence of provisional aborts that never ends with a
172 // committed load. 190 // committed load.
173 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); 191 void LogAbortChainHistograms(content::NavigationHandle* final_navigation);
174 192
175 // Whether the renderer should be sending timing IPCs to this page load. 193 // Whether the renderer should be sending timing IPCs to this page load.
176 bool renderer_tracked_; 194 bool renderer_tracked_;
177 195
178 // The navigation start in TimeTicks, not the wall time reported by Blink. 196 // The navigation start in TimeTicks, not the wall time reported by Blink.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 content::NavigationHandle* navigation_handle) override; 262 content::NavigationHandle* navigation_handle) override;
245 void DidFinishNavigation( 263 void DidFinishNavigation(
246 content::NavigationHandle* navigation_handle) override; 264 content::NavigationHandle* navigation_handle) override;
247 void DidRedirectNavigation( 265 void DidRedirectNavigation(
248 content::NavigationHandle* navigation_handle) override; 266 content::NavigationHandle* navigation_handle) override;
249 void NavigationStopped() override; 267 void NavigationStopped() override;
250 void WasShown() override; 268 void WasShown() override;
251 void WasHidden() override; 269 void WasHidden() override;
252 void RenderProcessGone(base::TerminationStatus status) override; 270 void RenderProcessGone(base::TerminationStatus status) override;
253 271
272 // This getter function is required for testing.
273 const PageLoadExtraInfo GetPageLoadExtraInfoCommittedLoad();
274
254 private: 275 private:
255 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 276 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
256 277
257 // Notify all loads, provisional and committed, that we performed an action 278 // Notify all loads, provisional and committed, that we performed an action
258 // that might abort them. 279 // that might abort them.
259 void NotifyAbortAllLoads(UserAbortType abort_type); 280 void NotifyAbortAllLoads(UserAbortType abort_type);
260 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, 281 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type,
261 base::TimeTicks timestamp); 282 base::TimeTicks timestamp,
283 bool is_browser_timetick);
262 // Notify aborted provisional loads that a new navigation occurred. This is 284 // Notify aborted provisional loads that a new navigation occurred. This is
263 // used for more consistent attribution tracking for aborted provisional 285 // used for more consistent attribution tracking for aborted provisional
264 // loads. This method returns the provisional load that was likely aborted by 286 // loads. This method returns the provisional load that was likely aborted by
265 // this navigation, to help instantiate the new PageLoadTracker. 287 // this navigation, to help instantiate the new PageLoadTracker.
266 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( 288 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation(
267 content::NavigationHandle* new_navigation); 289 content::NavigationHandle* new_navigation);
268 290
269 void OnTimingUpdated(content::RenderFrameHost*, 291 void OnTimingUpdated(content::RenderFrameHost*,
270 const PageLoadTiming& timing, 292 const PageLoadTiming& timing,
271 const PageLoadMetadata& metadata); 293 const PageLoadMetadata& metadata);
(...skipping 23 matching lines...) Expand all
295 317
296 // Has the MWCO observed at least one navigation? 318 // Has the MWCO observed at least one navigation?
297 bool has_navigated_; 319 bool has_navigated_;
298 320
299 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 321 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
300 }; 322 };
301 323
302 } // namespace page_load_metrics 324 } // namespace page_load_metrics
303 325
304 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 326 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698