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

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

Issue 2189543002: Notify page load metrics when the app enters the background. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clankbackgroundcallback
Patch Set: fix histogram description Created 4 years, 4 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 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>
(...skipping 23 matching lines...) Expand all
34 class PageLoadTracker; 34 class PageLoadTracker;
35 35
36 namespace internal { 36 namespace internal {
37 37
38 extern const char kErrorEvents[]; 38 extern const char kErrorEvents[];
39 extern const char kAbortChainSizeReload[]; 39 extern const char kAbortChainSizeReload[];
40 extern const char kAbortChainSizeForwardBack[]; 40 extern const char kAbortChainSizeForwardBack[];
41 extern const char kAbortChainSizeNewNavigation[]; 41 extern const char kAbortChainSizeNewNavigation[];
42 extern const char kAbortChainSizeNoCommit[]; 42 extern const char kAbortChainSizeNoCommit[];
43 extern const char kAbortChainSizeSameURL[]; 43 extern const char kAbortChainSizeSameURL[];
44 extern const char kPageLoadCompletedAfterAppBackground[];
44 45
45 } // namespace internal 46 } // namespace internal
46 47
47 // These errors are internal to the page_load_metrics subsystem and do not 48 // These errors are internal to the page_load_metrics subsystem and do not
48 // reflect actual errors that occur during a page load. 49 // reflect actual errors that occur during a page load.
49 // 50 //
50 // If you add elements to this enum, make sure you update the enum 51 // If you add elements to this enum, make sure you update the enum
51 // value in histograms.xml. Only add elements to the end to prevent 52 // value in histograms.xml. Only add elements to the end to prevent
52 // inconsistencies between versions. 53 // inconsistencies between versions.
53 enum InternalErrorLoadEvent { 54 enum InternalErrorLoadEvent {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 int aborted_chain_size_same_url); 137 int aborted_chain_size_same_url);
137 ~PageLoadTracker(); 138 ~PageLoadTracker();
138 void Redirect(content::NavigationHandle* navigation_handle); 139 void Redirect(content::NavigationHandle* navigation_handle);
139 void Commit(content::NavigationHandle* navigation_handle); 140 void Commit(content::NavigationHandle* navigation_handle);
140 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); 141 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle);
141 void WebContentsHidden(); 142 void WebContentsHidden();
142 void WebContentsShown(); 143 void WebContentsShown();
143 144
144 void OnInputEvent(const blink::WebInputEvent& event); 145 void OnInputEvent(const blink::WebInputEvent& event);
145 146
147 // Flush any buffered metrics, as part of the metrics subsystem persisting
148 // metrics as the application goes into the background. The application may be
149 // killed at any time after this method is invoked without further
150 // notification.
151 void FlushMetricsOnAppEnterBackground();
152
146 void NotifyClientRedirectTo(const PageLoadTracker& destination); 153 void NotifyClientRedirectTo(const PageLoadTracker& destination);
147 154
148 // Returns true if the timing was successfully updated. 155 // Returns true if the timing was successfully updated.
149 bool UpdateTiming(const PageLoadTiming& timing, 156 bool UpdateTiming(const PageLoadTiming& timing,
150 const PageLoadMetadata& metadata); 157 const PageLoadMetadata& metadata);
151 158
152 // Signals that we should stop tracking metrics for the associated page load. 159 // Signals that we should stop tracking metrics for the associated page load.
153 // We may stop tracking a page load if it doesn't meet the criteria for 160 // We may stop tracking a page load if it doesn't meet the criteria for
154 // tracking metrics in DidFinishNavigation. 161 // tracking metrics in DidFinishNavigation.
155 void StopTracking(); 162 void StopTracking();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // If |final_navigation| is null, then this is an "unparented" abort chain, 220 // If |final_navigation| is null, then this is an "unparented" abort chain,
214 // and represents a sequence of provisional aborts that never ends with a 221 // and represents a sequence of provisional aborts that never ends with a
215 // committed load. 222 // committed load.
216 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); 223 void LogAbortChainHistograms(content::NavigationHandle* final_navigation);
217 224
218 // Whether we stopped tracking this navigation after it was initiated. We may 225 // Whether we stopped tracking this navigation after it was initiated. We may
219 // stop tracking a navigation if it doesn't meet the criteria for tracking 226 // stop tracking a navigation if it doesn't meet the criteria for tracking
220 // metrics in DidFinishNavigation. 227 // metrics in DidFinishNavigation.
221 bool did_stop_tracking_; 228 bool did_stop_tracking_;
222 229
230 // Whether the application went into the background when this PageLoadTracker
231 // was active. This is a temporary boolean for UMA tracking.
232 bool app_entered_background_;
233
223 // The navigation start in TimeTicks, not the wall time reported by Blink. 234 // The navigation start in TimeTicks, not the wall time reported by Blink.
224 const base::TimeTicks navigation_start_; 235 const base::TimeTicks navigation_start_;
225 236
226 // Time this page load was committed. If this page load hasn't committed, 237 // Time this page load was committed. If this page load hasn't committed,
227 // |commit_time_| will be zero. 238 // |commit_time_| will be zero.
228 base::TimeTicks commit_time_; 239 base::TimeTicks commit_time_;
229 240
230 // The URL of this page load. This is the provisional url before commit 241 // The URL of this page load. This is the provisional url before commit
231 // (before redirects), and the committed url after commit. 242 // (before redirects), and the committed url after commit.
232 GURL url_; 243 GURL url_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void DidRedirectNavigation( 306 void DidRedirectNavigation(
296 content::NavigationHandle* navigation_handle) override; 307 content::NavigationHandle* navigation_handle) override;
297 void NavigationStopped() override; 308 void NavigationStopped() override;
298 void OnInputEvent(const blink::WebInputEvent& event) override; 309 void OnInputEvent(const blink::WebInputEvent& event) override;
299 void WasShown() override; 310 void WasShown() override;
300 void WasHidden() override; 311 void WasHidden() override;
301 void RenderProcessGone(base::TerminationStatus status) override; 312 void RenderProcessGone(base::TerminationStatus status) override;
302 void RenderViewHostChanged(content::RenderViewHost* old_host, 313 void RenderViewHostChanged(content::RenderViewHost* old_host,
303 content::RenderViewHost* new_host) override; 314 content::RenderViewHost* new_host) override;
304 315
316 // Flush any buffered metrics, as part of the metrics subsystem persisting
317 // metrics as the application goes into the background. The application may be
318 // killed at any time after this method is invoked without further
319 // notification.
320 void FlushMetricsOnAppEnterBackground();
321
305 // This getter function is required for testing. 322 // This getter function is required for testing.
306 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 323 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
307 324
308 private: 325 private:
309 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 326 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
310 327
311 void HandleFailedNavigationForTrackedLoad( 328 void HandleFailedNavigationForTrackedLoad(
312 content::NavigationHandle* navigation_handle, 329 content::NavigationHandle* navigation_handle,
313 std::unique_ptr<PageLoadTracker> tracker); 330 std::unique_ptr<PageLoadTracker> tracker);
314 331
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 383
367 // Has the MWCO observed at least one navigation? 384 // Has the MWCO observed at least one navigation?
368 bool has_navigated_; 385 bool has_navigated_;
369 386
370 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 387 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
371 }; 388 };
372 389
373 } // namespace page_load_metrics 390 } // namespace page_load_metrics
374 391
375 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 392 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698