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

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: FREEZE.unindexed - took merge and fixed it up 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const base::Optional<base::TimeDelta> page_end_time; 190 const base::Optional<base::TimeDelta> page_end_time;
191 191
192 // Extra information supplied to the page load metrics system from the 192 // Extra information supplied to the page load metrics system from the
193 // renderer for the main frame. 193 // renderer for the main frame.
194 const PageLoadMetadata main_frame_metadata; 194 const PageLoadMetadata main_frame_metadata;
195 195
196 // PageLoadMetadata for child frames of the current page load. 196 // PageLoadMetadata for child frames of the current page load.
197 const PageLoadMetadata child_frame_metadata; 197 const PageLoadMetadata child_frame_metadata;
198 }; 198 };
199 199
200 // Container for various information about a request within a page load. 200 // Container for various information about a completed request within a page
201 struct ExtraRequestInfo { 201 // load.
202 ExtraRequestInfo(bool was_cached, 202 struct ExtraRequestCompleteInfo {
203 int64_t raw_body_bytes, 203 ExtraRequestCompleteInfo(
204 int64_t original_network_content_length, 204 bool was_cached,
205 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> 205 int64_t raw_body_bytes,
206 data_reduction_proxy_data); 206 int64_t original_network_content_length,
207 std::unique_ptr<data_reduction_proxy::DataReductionProxyData>
208 data_reduction_proxy_data,
209 content::ResourceType detected_resource_type);
207 210
208 ~ExtraRequestInfo(); 211 ~ExtraRequestCompleteInfo();
209 212
210 // True if the resource was loaded from cache. 213 // True if the resource was loaded from cache.
211 const bool was_cached; 214 const bool was_cached;
212 215
213 // The number of body (not header) prefilter bytes. 216 // The number of body (not header) prefilter bytes.
214 const int64_t raw_body_bytes; 217 const int64_t raw_body_bytes;
215 218
216 // 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
217 // before it compressed the requests. 220 // before it compressed the requests.
218 const int64_t original_network_content_length; 221 const int64_t original_network_content_length;
219 222
220 // Data related to data saver. 223 // Data related to data saver.
221 const std::unique_ptr<data_reduction_proxy::DataReductionProxyData> 224 const std::unique_ptr<data_reduction_proxy::DataReductionProxyData>
222 data_reduction_proxy_data; 225 data_reduction_proxy_data;
226
227 // The type of the request as gleaned from the mime type. This may
228 // be more accurate than the type in the ExtraRequestStartInfo since we can
229 // examine the type headers that arrived with the request. During XHRs, we
230 // sometimes see resources come back as a different type than we expected.
231 const content::ResourceType resource_type;
232 };
233
234 // Container for various information about a started request within a page load.
235 struct ExtraRequestStartInfo {
236 explicit ExtraRequestStartInfo(content::ResourceType type);
237
238 ExtraRequestStartInfo(const ExtraRequestStartInfo& other);
239
240 ~ExtraRequestStartInfo();
241
242 // The type of the request as gleaned from the DOM or the file extension. This
243 // may be less accurate than the type at request completion time, which has
244 // access to mime-type headers. During XHRs, we sometimes see resources come
245 // back as a different type than we expected.
246 const content::ResourceType resource_type;
223 }; 247 };
224 248
225 // Interface for PageLoadMetrics observers. All instances of this class are 249 // Interface for PageLoadMetrics observers. All instances of this class are
226 // owned by the PageLoadTracker tracking a page load. 250 // owned by the PageLoadTracker tracking a page load.
227 class PageLoadMetricsObserver { 251 class PageLoadMetricsObserver {
228 public: 252 public:
229 // ObservePolicy is used as a return value on some PageLoadMetricsObserver 253 // ObservePolicy is used as a return value on some PageLoadMetricsObserver
230 // callbacks to indicate whether the observer would like to continue observing 254 // callbacks to indicate whether the observer would like to continue observing
231 // metric callbacks. Observers that wish to continue observing metric 255 // metric callbacks. Observers that wish to continue observing metric
232 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop 256 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // frequently on Android). 394 // frequently on Android).
371 virtual void OnComplete(const PageLoadTiming& timing, 395 virtual void OnComplete(const PageLoadTiming& timing,
372 const PageLoadExtraInfo& extra_info) {} 396 const PageLoadExtraInfo& extra_info) {}
373 397
374 // OnFailedProvisionalLoad is invoked for tracked page loads that did not 398 // OnFailedProvisionalLoad is invoked for tracked page loads that did not
375 // commit, immediately before the observer is deleted. 399 // commit, immediately before the observer is deleted.
376 virtual void OnFailedProvisionalLoad( 400 virtual void OnFailedProvisionalLoad(
377 const FailedProvisionalLoadInfo& failed_provisional_load_info, 401 const FailedProvisionalLoadInfo& failed_provisional_load_info,
378 const PageLoadExtraInfo& extra_info) {} 402 const PageLoadExtraInfo& extra_info) {}
379 403
404 // Called whenever a request load begins.
405 virtual void OnStartedResource(
406 const ExtraRequestStartInfo& extra_request_start_info) {}
407
380 // Called whenever a request is loaded for this page load. 408 // Called whenever a request is loaded for this page load.
381 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} 409 virtual void OnLoadedResource(
410 const ExtraRequestCompleteInfo& extra_request_complete_info) {}
382 }; 411 };
383 412
384 } // namespace page_load_metrics 413 } // namespace page_load_metrics
385 414
386 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ 415 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698