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

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

Issue 1357403003: Separate page load metrics for backgrounded pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Used DidFinishLoad instead of DidStopLoading Created 5 years, 3 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_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "components/page_load_metrics/common/page_load_timing.h" 10 #include "components/page_load_metrics/common/page_load_timing.h"
(...skipping 19 matching lines...) Expand all
30 public content::WebContentsUserData<MetricsWebContentsObserver> { 30 public content::WebContentsUserData<MetricsWebContentsObserver> {
31 public: 31 public:
32 ~MetricsWebContentsObserver() override; 32 ~MetricsWebContentsObserver() override;
33 33
34 // content::WebContentsObserver implementation: 34 // content::WebContentsObserver implementation:
35 bool OnMessageReceived(const IPC::Message& message, 35 bool OnMessageReceived(const IPC::Message& message,
36 content::RenderFrameHost* render_frame_host) override; 36 content::RenderFrameHost* render_frame_host) override;
37 void DidCommitNavigation( 37 void DidCommitNavigation(
38 content::NavigationHandle* navigation_handle) override; 38 content::NavigationHandle* navigation_handle) override;
39 void RenderProcessGone(base::TerminationStatus status) override; 39 void RenderProcessGone(base::TerminationStatus status) override;
40 void DidStartNavigation(
41 content::NavigationHandle* navigation_handle) override;
42 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
43 const GURL& validated_url) override;
44 void DidFailLoad(content::RenderFrameHost* render_frame_host,
45 const GURL& validated_url,
46 int error_code,
47 const base::string16& error_description,
48 bool was_ignored_by_handler) override;
49
50 void WasShown() override;
51 void WasHidden() override;
40 52
41 private: 53 private:
42 explicit MetricsWebContentsObserver(content::WebContents* web_contents); 54 explicit MetricsWebContentsObserver(content::WebContents* web_contents);
43 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 55 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
44 friend class MetricsWebContentsObserverTest; 56 friend class MetricsWebContentsObserverTest;
45 57
46 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing); 58 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing);
47 void RecordTimingHistograms(); 59 void RecordTimingHistograms();
48 60
49 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle); 61 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle);
50 62
51 // Will be null before any navigations have committed. When a navigation 63 // Will be null before any navigations have committed. When a navigation
52 // commits we will initialize this as empty. 64 // commits we will initialize this as empty.
53 scoped_ptr<PageLoadTiming> current_timing_; 65 scoped_ptr<PageLoadTiming> current_timing_;
54 66
67 // True if the web contents stayed in the foreground for the entire page load.
68 // We record separate metrics for any web contents that have been
69 // backgrounded, because metrics like layout/paint are delayed artificially
70 // when they occur in the bacground.
71 bool current_navigation_stayed_in_foreground_;
72
73 // True if the previous navigation stayed in the foreground.
74 bool previous_navigation_stayed_in_foreground_;
75
76 // True if the web contents is currently in the foreground.
77 bool in_foreground_;
78
55 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 79 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
56 }; 80 };
57 81
58 } // namespace page_load_metrics 82 } // namespace page_load_metrics
59 83
60 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ 84 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698