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

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 bmcquade 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 completed request within a page
199 struct ExtraRequestInfo { 199 // load.
200 ExtraRequestInfo(bool was_cached, 200 struct ExtraRequestCompleteInfo {
201 int64_t raw_body_bytes, 201 ExtraRequestCompleteInfo(bool was_cached,
202 bool data_reduction_proxy_used, 202 int64_t raw_body_bytes,
203 int64_t original_network_content_length); 203 bool data_reduction_proxy_used,
204 int64_t original_network_content_length,
205 content::ResourceType detected_resource_type);
204 206
205 ExtraRequestInfo(const ExtraRequestInfo& other); 207 ExtraRequestCompleteInfo(const ExtraRequestCompleteInfo& other);
206 208
207 ~ExtraRequestInfo(); 209 ~ExtraRequestCompleteInfo();
208 210
209 // True if the resource was loaded from cache. 211 // True if the resource was loaded from cache.
210 const bool was_cached; 212 const bool was_cached;
211 213
212 // The number of body (not header) prefilter bytes. 214 // The number of body (not header) prefilter bytes.
213 const int64_t raw_body_bytes; 215 const int64_t raw_body_bytes;
214 216
215 // Whether this request used Data Reduction Proxy. 217 // Whether this request used Data Reduction Proxy.
216 const bool data_reduction_proxy_used; 218 const bool data_reduction_proxy_used;
217 219
218 // The number of body (not header) bytes that the data reduction proxy saw 220 // The number of body (not header) bytes that the data reduction proxy saw
219 // before it compressed the requests. 221 // before it compressed the requests.
220 const int64_t original_network_content_length; 222 const int64_t original_network_content_length;
223
224 // The type of the request as gleaned from the ResourceRequestInfo.
Bryan McQuade 2017/04/24 13:56:55 i think someone noted in a previous comment that t
Pete Williamson 2017/04/24 19:53:14 Done.
225 const content::ResourceType resource_type;
226 };
227
228 // Container for various information about a started request within a page load.
229 struct ExtraRequestStartInfo {
230 explicit ExtraRequestStartInfo(content::ResourceType type);
231
232 ExtraRequestStartInfo(const ExtraRequestStartInfo& other);
233
234 ~ExtraRequestStartInfo();
235
236 // The type of the request as gleaned from the ResourceRequestInfo.
237 const content::ResourceType resource_type;
221 }; 238 };
222 239
223 // Interface for PageLoadMetrics observers. All instances of this class are 240 // Interface for PageLoadMetrics observers. All instances of this class are
224 // owned by the PageLoadTracker tracking a page load. 241 // owned by the PageLoadTracker tracking a page load.
225 class PageLoadMetricsObserver { 242 class PageLoadMetricsObserver {
226 public: 243 public:
227 // ObservePolicy is used as a return value on some PageLoadMetricsObserver 244 // ObservePolicy is used as a return value on some PageLoadMetricsObserver
228 // callbacks to indicate whether the observer would like to continue observing 245 // callbacks to indicate whether the observer would like to continue observing
229 // metric callbacks. Observers that wish to continue observing metric 246 // metric callbacks. Observers that wish to continue observing metric
230 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop 247 // 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). 385 // frequently on Android).
369 virtual void OnComplete(const PageLoadTiming& timing, 386 virtual void OnComplete(const PageLoadTiming& timing,
370 const PageLoadExtraInfo& extra_info) {} 387 const PageLoadExtraInfo& extra_info) {}
371 388
372 // OnFailedProvisionalLoad is invoked for tracked page loads that did not 389 // OnFailedProvisionalLoad is invoked for tracked page loads that did not
373 // commit, immediately before the observer is deleted. 390 // commit, immediately before the observer is deleted.
374 virtual void OnFailedProvisionalLoad( 391 virtual void OnFailedProvisionalLoad(
375 const FailedProvisionalLoadInfo& failed_provisional_load_info, 392 const FailedProvisionalLoadInfo& failed_provisional_load_info,
376 const PageLoadExtraInfo& extra_info) {} 393 const PageLoadExtraInfo& extra_info) {}
377 394
395 // Called whenever a request load begins.
396 virtual void OnStartedResource(
397 const ExtraRequestStartInfo& extra_request_start_info) {}
398
378 // Called whenever a request is loaded for this page load. 399 // Called whenever a request is loaded for this page load.
379 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} 400 virtual void OnLoadedResource(
401 const ExtraRequestCompleteInfo& extra_request_complete_info) {}
380 }; 402 };
381 403
382 } // namespace page_load_metrics 404 } // namespace page_load_metrics
383 405
384 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ 406 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698