Index: components/page_load_metrics/browser/metrics_web_contents_observer.h |
diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.h b/components/page_load_metrics/browser/metrics_web_contents_observer.h |
index 6bc29040d4d7eb5efa9a29b3a6c13ad1f321cea2..7b73c5a17de5af1b22625069ee6accbc03e9f6c1 100644 |
--- a/components/page_load_metrics/browser/metrics_web_contents_observer.h |
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer.h |
@@ -117,7 +117,8 @@ enum ProvisionalLoadEvent { |
PROVISIONAL_LOAD_LAST_ENTRY |
}; |
-// CommittedLoadEvents are events that occur on committed loads that we track. |
+// CommittedRelevantLoadEvents are events that occur on committed loads that we |
+// track. |
// Note that we capture events only for committed loads that: |
// - Are http/https. |
// - Not same-page navigations. |
@@ -127,21 +128,21 @@ enum ProvisionalLoadEvent { |
// If you add elements to this enum, make sure you update the enum |
// value in histograms.xml. Only add elements to the end to prevent |
// inconsistencies between versions. |
-enum CommittedLoadEvent { |
+enum CommittedRelevantLoadEvent { |
// When a load that eventually commits started. Note we can't log this until |
// commit time, but it represents when the actual page load started. Thus, we |
// only separate this into .Background when a page load starts backgrounded. |
- COMMITTED_LOAD_STARTED, |
+ RELEVANT_LOAD_STARTED, |
// These two events are disjoint. Sum them to find the total number of |
// committed loads that we end up tracking. |
- COMMITTED_LOAD_FAILED_BEFORE_FIRST_LAYOUT, |
- COMMITTED_LOAD_SUCCESSFUL_FIRST_LAYOUT, |
+ RELEVANT_LOAD_FAILED_BEFORE_FIRST_LAYOUT, |
+ RELEVANT_LOAD_SUCCESSFUL_FIRST_LAYOUT, |
// TODO(csharrison) once first paint metrics are in place, add new events. |
// Add values before this final count. |
- COMMITTED_LOAD_LAST_ENTRY |
+ RELEVANT_LOAD_LAST_ENTRY |
}; |
// These errors are internal to the page_load_metrics subsystem and do not |
@@ -162,7 +163,7 @@ enum InternalErrorLoadEvent { |
// We received an IPC when we weren't tracking a committed load. This will |
// often happen if we get an IPC from a bad URL scheme (that is, the renderer |
// sent us an IPC from a navigation we don't care about). |
- ERR_IPC_WITH_NO_COMMITTED_LOAD, |
+ ERR_IPC_WITH_NO_RELEVANT_LOAD, |
// Received a notification from a frame that has been navigated away from. |
ERR_IPC_FROM_WRONG_FRAME, |
@@ -170,7 +171,7 @@ enum InternalErrorLoadEvent { |
// We received an IPC even through the last committed url from the browser |
// was not http/s. This can happen with the renderer sending IPCs for the |
// new tab page. This will often come paired with |
- // ERR_IPC_WITH_NO_COMMITTED_LOAD. |
+ // ERR_IPC_WITH_NO_RELEVANT_LOAD. |
ERR_IPC_FROM_BAD_URL_SCHEME, |
// If we track a navigation, but the renderer sends us no IPCs. This could |
@@ -188,6 +189,7 @@ class PageLoadMetricsEmbedderInterface { |
virtual ~PageLoadMetricsEmbedderInterface() {} |
virtual rappor::RapporService* GetRapporService() = 0; |
virtual bool IsPrerendering(content::WebContents* web_contents) = 0; |
+ virtual void RegisterObservers(PageLoadMetricsObservable* metrics) = 0; |
}; |
// This class tracks a given page load, starting from navigation start / |
@@ -195,15 +197,14 @@ class PageLoadMetricsEmbedderInterface { |
// also records RAPPOR/UMA about the page load. |
// MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as |
// well as a committed PageLoadTracker. |
-class PageLoadTracker { |
+class PageLoadTracker : public PageLoadMetricsObservable { |
public: |
- // Caller must guarantee that the observers and embedder_interface pointers |
- // outlives this class. |
+ // Caller must guarantee that the embedder_interface pointers outlives this |
+ // class. |
PageLoadTracker(bool in_foreground, |
PageLoadMetricsEmbedderInterface* embedder_interface, |
- content::NavigationHandle* navigation_handle, |
- base::ObserverList<PageLoadMetricsObserver, true>* observers); |
- ~PageLoadTracker(); |
+ content::NavigationHandle* navigation_handle); |
+ ~PageLoadTracker() override; |
void Redirect(content::NavigationHandle* navigation_handle); |
void Commit(content::NavigationHandle* navigation_handle); |
void WebContentsHidden(); |
@@ -212,18 +213,29 @@ class PageLoadTracker { |
// Returns true if the timing was successfully updated. |
bool UpdateTiming(const PageLoadTiming& timing); |
void RecordProvisionalEvent(ProvisionalLoadEvent event); |
- void RecordCommittedEvent(CommittedLoadEvent event, bool backgrounded); |
+ void RecordCommittedEvent(CommittedRelevantLoadEvent event, |
+ bool backgrounded); |
bool HasBackgrounded(); |
+ void set_renderer_tracked(bool renderer_tracked); |
+ bool renderer_tracked() { return renderer_tracked_; } |
+ |
+ // PageLoadMetricsObservable implementation |
+ void AddObserver(PageLoadMetricsObserver* observer) override; |
+ void RemoveObserver(PageLoadMetricsObserver* observer) override; |
+ |
private: |
PageLoadExtraInfo GetPageLoadMetricsInfo(); |
// Only valid to call post-commit. |
- const GURL& GetCommittedURL(); |
+ const GURL& committed_url(); |
base::TimeDelta GetBackgroundDelta(); |
void RecordTimingHistograms(); |
void RecordRappor(); |
+ // Whether the renderer should be sending timing IPCs to this page load. |
+ bool renderer_tracked_; |
+ |
bool has_commit_; |
// The navigation start in TimeTicks, not the wall time reported by Blink. |
@@ -242,8 +254,7 @@ class PageLoadTracker { |
// Interface to chrome features. Must outlive the class. |
PageLoadMetricsEmbedderInterface* const embedder_interface_; |
- // List of observers. This must outlive the class. |
- base::ObserverList<PageLoadMetricsObserver, true>* observers_; |
+ base::ObserverList<PageLoadMetricsObserver, true> observers_; |
DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
}; |
@@ -252,8 +263,7 @@ class PageLoadTracker { |
// IPC messages received from a MetricsRenderFrameObserver. |
class MetricsWebContentsObserver |
: public content::WebContentsObserver, |
- public content::WebContentsUserData<MetricsWebContentsObserver>, |
- public PageLoadMetricsObservable { |
+ public content::WebContentsUserData<MetricsWebContentsObserver> { |
public: |
// Note that the returned metrics is owned by the web contents. |
// The caller must guarantee that the RapporService (if non-null) will |
@@ -266,9 +276,6 @@ class MetricsWebContentsObserver |
scoped_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); |
~MetricsWebContentsObserver() override; |
- void AddObserver(PageLoadMetricsObserver* observer) override; |
- void RemoveObserver(PageLoadMetricsObserver* observer) override; |
- |
// content::WebContentsObserver implementation: |
bool OnMessageReceived(const IPC::Message& message, |
content::RenderFrameHost* render_frame_host) override; |
@@ -301,7 +308,6 @@ class MetricsWebContentsObserver |
scoped_ptr<PageLoadTracker> committed_load_; |
scoped_ptr<PageLoadMetricsEmbedderInterface> embedder_interface_; |
- base::ObserverList<PageLoadMetricsObserver, true> observers_; |
DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
}; |