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

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

Issue 2780003003: Send an event to the page load metrics to track resource starting. (Closed)
Patch Set: CR feedback per RyanSturm Created 3 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
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_PAGE_LOAD_METRICS_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const base::Optional<base::TimeDelta> page_end_time; 188 const base::Optional<base::TimeDelta> page_end_time;
189 189
190 // Extra information supplied to the page load metrics system from the 190 // Extra information supplied to the page load metrics system from the
191 // renderer for the main frame. 191 // renderer for the main frame.
192 const PageLoadMetadata main_frame_metadata; 192 const PageLoadMetadata main_frame_metadata;
193 193
194 // PageLoadMetadata for child frames of the current page load. 194 // PageLoadMetadata for child frames of the current page load.
195 const PageLoadMetadata child_frame_metadata; 195 const PageLoadMetadata child_frame_metadata;
196 }; 196 };
197 197
198 // Container for various information about a request within a page load. 198 // Container for various information about a request within a page load.
RyanSturm 2017/04/17 19:57:08 nit: s/about a request/about a completed request/
Pete Williamson 2017/04/17 20:46:36 Done.
199 struct ExtraRequestInfo { 199 struct ExtraRequestCompleteInfo {
200 ExtraRequestInfo(bool was_cached, 200 ExtraRequestCompleteInfo(bool was_cached,
201 int64_t raw_body_bytes, 201 int64_t raw_body_bytes,
202 bool data_reduction_proxy_used, 202 bool data_reduction_proxy_used,
203 int64_t original_network_content_length); 203 int64_t original_network_content_length,
204 content::ResourceType found_type);
204 205
205 ExtraRequestInfo(const ExtraRequestInfo& other); 206 ExtraRequestCompleteInfo(const ExtraRequestCompleteInfo& other);
206 207
207 ~ExtraRequestInfo(); 208 ~ExtraRequestCompleteInfo();
208 209
209 // True if the resource was loaded from cache. 210 // True if the resource was loaded from cache.
210 const bool was_cached; 211 const bool was_cached;
211 212
212 // The number of body (not header) prefilter bytes. 213 // The number of body (not header) prefilter bytes.
213 const int64_t raw_body_bytes; 214 const int64_t raw_body_bytes;
214 215
215 // Whether this request used Data Reduction Proxy. 216 // Whether this request used Data Reduction Proxy.
216 const bool data_reduction_proxy_used; 217 const bool data_reduction_proxy_used;
217 218
218 // The number of body (not header) bytes that the data reduction proxy saw 219 // The number of body (not header) bytes that the data reduction proxy saw
219 // before it compressed the requests. 220 // before it compressed the requests.
220 const int64_t original_network_content_length; 221 const int64_t original_network_content_length;
222
223 // The type of the request as gleaned from the ResourceRequestInfo.
224 const content::ResourceType resource_type;
225 };
226
227 // Container for various information about a request within a page load.
RyanSturm 2017/04/17 19:57:08 nit: s/about a request/about a started request/
Pete Williamson 2017/04/17 20:46:36 Done.
228 struct ExtraRequestStartInfo {
229 explicit ExtraRequestStartInfo(content::ResourceType type);
230
231 ExtraRequestStartInfo(const ExtraRequestStartInfo& other);
232
233 ~ExtraRequestStartInfo();
234
235 // The type of the request as gleaned from the ResourceRequestInfo.
236 const content::ResourceType resource_type;
221 }; 237 };
222 238
223 // Interface for PageLoadMetrics observers. All instances of this class are 239 // Interface for PageLoadMetrics observers. All instances of this class are
224 // owned by the PageLoadTracker tracking a page load. 240 // owned by the PageLoadTracker tracking a page load.
225 class PageLoadMetricsObserver { 241 class PageLoadMetricsObserver {
226 public: 242 public:
227 // ObservePolicy is used as a return value on some PageLoadMetricsObserver 243 // ObservePolicy is used as a return value on some PageLoadMetricsObserver
228 // callbacks to indicate whether the observer would like to continue observing 244 // callbacks to indicate whether the observer would like to continue observing
229 // metric callbacks. Observers that wish to continue observing metric 245 // metric callbacks. Observers that wish to continue observing metric
230 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop 246 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // frequently on Android). 384 // frequently on Android).
369 virtual void OnComplete(const PageLoadTiming& timing, 385 virtual void OnComplete(const PageLoadTiming& timing,
370 const PageLoadExtraInfo& extra_info) {} 386 const PageLoadExtraInfo& extra_info) {}
371 387
372 // OnFailedProvisionalLoad is invoked for tracked page loads that did not 388 // OnFailedProvisionalLoad is invoked for tracked page loads that did not
373 // commit, immediately before the observer is deleted. 389 // commit, immediately before the observer is deleted.
374 virtual void OnFailedProvisionalLoad( 390 virtual void OnFailedProvisionalLoad(
375 const FailedProvisionalLoadInfo& failed_provisional_load_info, 391 const FailedProvisionalLoadInfo& failed_provisional_load_info,
376 const PageLoadExtraInfo& extra_info) {} 392 const PageLoadExtraInfo& extra_info) {}
377 393
394 // Called whenever a request load begins.
395 virtual void OnStartedResource(
396 const ExtraRequestStartInfo& extra_request_start_info) {}
397
378 // Called whenever a request is loaded for this page load. 398 // Called whenever a request is loaded for this page load.
379 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} 399 virtual void OnLoadedResource(
400 const ExtraRequestCompleteInfo& extra_request_complete_info) {}
380 }; 401 };
381 402
382 } // namespace page_load_metrics 403 } // namespace page_load_metrics
383 404
384 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ 405 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698