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

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: Fix browser tests 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
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
224 // ChromeResourceDispatcherHostDelegate.
RyanSturm 2017/04/14 20:08:43 I'd adjust this comment to say "from ResourceReque
Pete Williamson 2017/04/17 18:53:11 Done in both places.
225 const content::ResourceType resource_type;
226 };
227
228 // Container for various information about a 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
237 // ChromeResourceDispatcherHostDelegate.
238 const content::ResourceType resource_type;
221 }; 239 };
222 240
223 // Interface for PageLoadMetrics observers. All instances of this class are 241 // Interface for PageLoadMetrics observers. All instances of this class are
224 // owned by the PageLoadTracker tracking a page load. 242 // owned by the PageLoadTracker tracking a page load.
225 class PageLoadMetricsObserver { 243 class PageLoadMetricsObserver {
226 public: 244 public:
227 // ObservePolicy is used as a return value on some PageLoadMetricsObserver 245 // ObservePolicy is used as a return value on some PageLoadMetricsObserver
228 // callbacks to indicate whether the observer would like to continue observing 246 // callbacks to indicate whether the observer would like to continue observing
229 // metric callbacks. Observers that wish to continue observing metric 247 // metric callbacks. Observers that wish to continue observing metric
230 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop 248 // 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). 386 // frequently on Android).
369 virtual void OnComplete(const PageLoadTiming& timing, 387 virtual void OnComplete(const PageLoadTiming& timing,
370 const PageLoadExtraInfo& extra_info) {} 388 const PageLoadExtraInfo& extra_info) {}
371 389
372 // OnFailedProvisionalLoad is invoked for tracked page loads that did not 390 // OnFailedProvisionalLoad is invoked for tracked page loads that did not
373 // commit, immediately before the observer is deleted. 391 // commit, immediately before the observer is deleted.
374 virtual void OnFailedProvisionalLoad( 392 virtual void OnFailedProvisionalLoad(
375 const FailedProvisionalLoadInfo& failed_provisional_load_info, 393 const FailedProvisionalLoadInfo& failed_provisional_load_info,
376 const PageLoadExtraInfo& extra_info) {} 394 const PageLoadExtraInfo& extra_info) {}
377 395
396 // Called whenever a request load begins.
397 virtual void OnStartedResource(
398 const ExtraRequestStartInfo& extra_request_start_info) {}
399
378 // Called whenever a request is loaded for this page load. 400 // Called whenever a request is loaded for this page load.
379 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} 401 virtual void OnLoadedResource(
402 const ExtraRequestCompleteInfo& extra_request_complete_info) {}
380 }; 403 };
381 404
382 } // namespace page_load_metrics 405 } // namespace page_load_metrics
383 406
384 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ 407 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698