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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

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 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // investigation is needed to confirm that all cases would be handled 245 // investigation is needed to confirm that all cases would be handled
246 // correctly (for example Link: preloads). 246 // correctly (for example Link: preloads).
247 if (committed_load_ && 247 if (committed_load_ &&
248 creation_time >= committed_load_->navigation_start()) { 248 creation_time >= committed_load_->navigation_start()) {
249 return committed_load_.get(); 249 return committed_load_.get();
250 } 250 }
251 } 251 }
252 return nullptr; 252 return nullptr;
253 } 253 }
254 254
255 void MetricsWebContentsObserver::OnRequestStarted(
256 const content::GlobalRequestID& request_id,
257 content::ResourceType resource_type,
258 base::TimeTicks creation_time) {
259 // Note for the main HTML page, the tracker may not exist yet, so
Bryan McQuade 2017/04/24 13:56:55 interesting - the fact that the tracker doesn't ex
Pete Williamson 2017/04/24 19:53:14 Done.
260 // OnStartedResource will not be called for the main page. While the main
261 // page is not being tracked today, if we do decide to track it, we will need
262 // to first make sure that GlobalRequestID is set in an earlier callback.
263 PageLoadTracker* tracker =
264 GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
265 if (tracker) {
266 ExtraRequestStartInfo extra_request_start_info(resource_type);
267 tracker->OnStartedResource(extra_request_start_info);
268 }
269 }
270
255 void MetricsWebContentsObserver::OnRequestComplete( 271 void MetricsWebContentsObserver::OnRequestComplete(
256 const content::GlobalRequestID& request_id, 272 const content::GlobalRequestID& request_id,
257 content::ResourceType resource_type, 273 content::ResourceType resource_type,
258 bool was_cached, 274 bool was_cached,
259 bool used_data_reduction_proxy, 275 bool used_data_reduction_proxy,
260 int64_t raw_body_bytes, 276 int64_t raw_body_bytes,
261 int64_t original_content_length, 277 int64_t original_content_length,
262 base::TimeTicks creation_time) { 278 base::TimeTicks creation_time) {
263 PageLoadTracker* tracker = 279 PageLoadTracker* tracker =
264 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); 280 GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
265 if (tracker) { 281 if (tracker) {
266 ExtraRequestInfo extra_request_info( 282 ExtraRequestCompleteInfo extra_request_complete_info(
267 was_cached, raw_body_bytes, used_data_reduction_proxy, 283 was_cached, raw_body_bytes, used_data_reduction_proxy,
268 was_cached ? 0 : original_content_length); 284 was_cached ? 0 : original_content_length, resource_type);
269 tracker->OnLoadedResource(extra_request_info); 285 tracker->OnLoadedResource(extra_request_complete_info);
270 } 286 }
271 } 287 }
272 288
273 void MetricsWebContentsObserver::OnNavigationDelayComplete( 289 void MetricsWebContentsObserver::OnNavigationDelayComplete(
274 content::NavigationHandle* navigation_handle, 290 content::NavigationHandle* navigation_handle,
275 base::TimeDelta scheduled_delay, 291 base::TimeDelta scheduled_delay,
276 base::TimeDelta actual_delay) { 292 base::TimeDelta actual_delay) {
277 auto it = provisional_loads_.find(navigation_handle); 293 auto it = provisional_loads_.find(navigation_handle);
278 if (it == provisional_loads_.end()) 294 if (it == provisional_loads_.end())
279 return; 295 return;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 content::NavigationHandle* navigation_handle) const { 600 content::NavigationHandle* navigation_handle) const {
585 DCHECK(navigation_handle->IsInMainFrame()); 601 DCHECK(navigation_handle->IsInMainFrame());
586 DCHECK(!navigation_handle->HasCommitted() || 602 DCHECK(!navigation_handle->HasCommitted() ||
587 !navigation_handle->IsSameDocument()); 603 !navigation_handle->IsSameDocument());
588 604
589 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 605 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
590 navigation_handle).ShouldTrack(); 606 navigation_handle).ShouldTrack();
591 } 607 }
592 608
593 } // namespace page_load_metrics 609 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698