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

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

Issue 1900343003: Provide currently_committed_url to PageLoadMetricsObservers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | components/page_load_metrics/browser/metrics_web_contents_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 9 #include <vector>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 virtual void RegisterObservers(PageLoadTracker* metrics) = 0; 99 virtual void RegisterObservers(PageLoadTracker* metrics) = 0;
100 }; 100 };
101 101
102 // This class tracks a given page load, starting from navigation start / 102 // This class tracks a given page load, starting from navigation start /
103 // provisional load, until a new navigation commits or the navigation fails. 103 // provisional load, until a new navigation commits or the navigation fails.
104 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as 104 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as
105 // well as a committed PageLoadTracker. 105 // well as a committed PageLoadTracker.
106 class PageLoadTracker { 106 class PageLoadTracker {
107 public: 107 public:
108 // Caller must guarantee that the embedder_interface pointer outlives this 108 // Caller must guarantee that the embedder_interface pointer outlives this
109 // class. 109 // class. The PageLoadTracker must not hold on to
110 // currently_committed_load_or_null or navigation_handle beyond the scope of
111 // the constructor.
110 PageLoadTracker(bool in_foreground, 112 PageLoadTracker(bool in_foreground,
111 PageLoadMetricsEmbedderInterface* embedder_interface, 113 PageLoadMetricsEmbedderInterface* embedder_interface,
114 PageLoadTracker* const currently_committed_load_or_null,
112 content::NavigationHandle* navigation_handle, 115 content::NavigationHandle* navigation_handle,
113 int aborted_chain_size, 116 int aborted_chain_size,
114 int aborted_chain_size_same_url); 117 int aborted_chain_size_same_url);
115 ~PageLoadTracker(); 118 ~PageLoadTracker();
116 void Redirect(content::NavigationHandle* navigation_handle); 119 void Redirect(content::NavigationHandle* navigation_handle);
117 void Commit(content::NavigationHandle* navigation_handle); 120 void Commit(content::NavigationHandle* navigation_handle);
118 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); 121 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle);
119 void WebContentsHidden(); 122 void WebContentsHidden();
120 void WebContentsShown(); 123 void WebContentsShown();
121 124
122 // Returns true if the timing was successfully updated. 125 // Returns true if the timing was successfully updated.
123 bool UpdateTiming(const PageLoadTiming& timing, 126 bool UpdateTiming(const PageLoadTiming& timing,
124 const PageLoadMetadata& metadata); 127 const PageLoadMetadata& metadata);
125 bool HasBackgrounded();
126 128
127 void set_renderer_tracked(bool renderer_tracked); 129 void set_renderer_tracked(bool renderer_tracked);
128 bool renderer_tracked() const { return renderer_tracked_; } 130 bool renderer_tracked() const { return renderer_tracked_; }
129 131
130 int aborted_chain_size() const { return aborted_chain_size_; } 132 int aborted_chain_size() const { return aborted_chain_size_; }
131 int aborted_chain_size_same_url() const { 133 int aborted_chain_size_same_url() const {
132 return aborted_chain_size_same_url_; 134 return aborted_chain_size_same_url_;
133 } 135 }
134 136
135 UserAbortType abort_type() const { return abort_type_; } 137 UserAbortType abort_type() const { return abort_type_; }
136 base::TimeTicks abort_time() const { return abort_time_; } 138 base::TimeTicks abort_time() const { return abort_time_; }
137 139
138 void AddObserver(scoped_ptr<PageLoadMetricsObserver> observer); 140 void AddObserver(scoped_ptr<PageLoadMetricsObserver> observer);
139 141
140 // If the user performs some abort-like action while we are tracking this page 142 // If the user performs some abort-like action while we are tracking this page
141 // load, notify the tracker. Note that we may not classify this as an abort if 143 // load, notify the tracker. Note that we may not classify this as an abort if
142 // we've already performed a first paint. 144 // we've already performed a first paint.
143 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp); 145 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp);
144 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp); 146 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp);
145 147
146 // This method returns true if this page load has been aborted with type of 148 // This method returns true if this page load has been aborted with type of
147 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 149 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close
148 // delta to when it was aborted. Note that only provisional loads can be 150 // delta to when it was aborted. Note that only provisional loads can be
149 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 151 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better
150 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 152 // and is simpler than other feasible methods. See https://goo.gl/WKRG98.
151 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); 153 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time);
152 154
153 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); 155 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle);
154 156
157 // Only valid to call post-commit.
158 const GURL& committed_url() const {
159 DCHECK(!commit_time_.is_null());
160 return url_;
161 }
162
155 private: 163 private:
156 PageLoadExtraInfo GetPageLoadMetricsInfo(); 164 PageLoadExtraInfo GetPageLoadMetricsInfo();
157 165
158 // Only valid to call post-commit.
159 const GURL& committed_url();
160
161 void UpdateAbortInternal(UserAbortType abort_type, 166 void UpdateAbortInternal(UserAbortType abort_type,
162 base::TimeTicks timestamp); 167 base::TimeTicks timestamp);
163 168
164 // If |final_navigation| is null, then this is an "unparented" abort chain, 169 // If |final_navigation| is null, then this is an "unparented" abort chain,
165 // and represents a sequence of provisional aborts that never ends with a 170 // and represents a sequence of provisional aborts that never ends with a
166 // committed load. 171 // committed load.
167 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); 172 void LogAbortChainHistograms(content::NavigationHandle* final_navigation);
168 173
169 // Whether the renderer should be sending timing IPCs to this page load. 174 // Whether the renderer should be sending timing IPCs to this page load.
170 bool renderer_tracked_; 175 bool renderer_tracked_;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 std::vector<scoped_ptr<PageLoadTracker>> aborted_provisional_loads_; 291 std::vector<scoped_ptr<PageLoadTracker>> aborted_provisional_loads_;
287 292
288 scoped_ptr<PageLoadTracker> committed_load_; 293 scoped_ptr<PageLoadTracker> committed_load_;
289 294
290 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 295 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
291 }; 296 };
292 297
293 } // namespace page_load_metrics 298 } // namespace page_load_metrics
294 299
295 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 300 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | components/page_load_metrics/browser/metrics_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698