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

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

Issue 2321083002: [NoStatePrefetch] Add performance histograms. (Closed)
Patch Set: Review comments Created 4 years, 3 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 bool in_foreground, 283 bool in_foreground,
284 PageLoadMetricsEmbedderInterface* embedder_interface, 284 PageLoadMetricsEmbedderInterface* embedder_interface,
285 const GURL& currently_committed_url, 285 const GURL& currently_committed_url,
286 content::NavigationHandle* navigation_handle, 286 content::NavigationHandle* navigation_handle,
287 int aborted_chain_size, 287 int aborted_chain_size,
288 int aborted_chain_size_same_url) 288 int aborted_chain_size_same_url)
289 : did_stop_tracking_(false), 289 : did_stop_tracking_(false),
290 app_entered_background_(false), 290 app_entered_background_(false),
291 navigation_start_(navigation_handle->NavigationStart()), 291 navigation_start_(navigation_handle->NavigationStart()),
292 url_(navigation_handle->GetURL()), 292 url_(navigation_handle->GetURL()),
293 start_url_(url_),
293 abort_type_(ABORT_NONE), 294 abort_type_(ABORT_NONE),
294 abort_user_initiated_(false), 295 abort_user_initiated_(false),
295 started_in_foreground_(in_foreground), 296 started_in_foreground_(in_foreground),
296 page_transition_(navigation_handle->GetPageTransition()), 297 page_transition_(navigation_handle->GetPageTransition()),
297 num_cache_requests_(0), 298 num_cache_requests_(0),
298 num_network_requests_(0), 299 num_network_requests_(0),
299 user_gesture_(IsNavigationUserInitiated(navigation_handle)), 300 user_gesture_(IsNavigationUserInitiated(navigation_handle)),
300 aborted_chain_size_(aborted_chain_size), 301 aborted_chain_size_(aborted_chain_size),
301 aborted_chain_size_same_url_(aborted_chain_size_same_url), 302 aborted_chain_size_same_url_(aborted_chain_size_same_url),
302 embedder_interface_(embedder_interface) { 303 embedder_interface_(embedder_interface) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // different start time from an earlier struct is considered invalid. 490 // different start time from an earlier struct is considered invalid.
490 bool valid_timing_descendent = 491 bool valid_timing_descendent =
491 timing_.navigation_start.is_null() || 492 timing_.navigation_start.is_null() ||
492 timing_.navigation_start == new_timing.navigation_start; 493 timing_.navigation_start == new_timing.navigation_start;
493 // Ensure flags sent previously are still present in the new metadata fields. 494 // Ensure flags sent previously are still present in the new metadata fields.
494 bool valid_behavior_descendent = 495 bool valid_behavior_descendent =
495 (metadata_.behavior_flags & new_metadata.behavior_flags) == 496 (metadata_.behavior_flags & new_metadata.behavior_flags) ==
496 metadata_.behavior_flags; 497 metadata_.behavior_flags;
497 if (IsValidPageLoadTiming(new_timing) && valid_timing_descendent && 498 if (IsValidPageLoadTiming(new_timing) && valid_timing_descendent &&
498 valid_behavior_descendent) { 499 valid_behavior_descendent) {
500 DCHECK(!commit_time_.is_null()); // OnCommit() must be called first.
499 // There are some subtle ordering constraints here. GetPageLoadMetricsInfo() 501 // There are some subtle ordering constraints here. GetPageLoadMetricsInfo()
500 // must be called before DispatchObserverTimingCallbacks, but its 502 // must be called before DispatchObserverTimingCallbacks, but its
501 // implementation depends on the state of metadata_, so we need to update 503 // implementation depends on the state of metadata_, so we need to update
502 // metadata_ before calling GetPageLoadMetricsInfo. Thus, we make a copy of 504 // metadata_ before calling GetPageLoadMetricsInfo. Thus, we make a copy of
503 // timing here, update timing_ and metadata_, and then proceed to dispatch 505 // timing here, update timing_ and metadata_, and then proceed to dispatch
504 // the observer timing callbacks. 506 // the observer timing callbacks.
505 const PageLoadTiming last_timing = timing_; 507 const PageLoadTiming last_timing = timing_;
506 timing_ = new_timing; 508 timing_ = new_timing;
507 509
508 const PageLoadMetadata last_metadata = metadata_; 510 const PageLoadMetadata last_metadata = metadata_;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 588
587 if (!commit_time_.is_null()) { 589 if (!commit_time_.is_null()) {
588 DCHECK_GE(commit_time_, navigation_start_); 590 DCHECK_GE(commit_time_, navigation_start_);
589 time_to_commit = commit_time_ - navigation_start_; 591 time_to_commit = commit_time_ - navigation_start_;
590 } 592 }
591 593
592 // abort_type_ == ABORT_NONE implies !abort_user_initiated_. 594 // abort_type_ == ABORT_NONE implies !abort_user_initiated_.
593 DCHECK(abort_type_ != ABORT_NONE || !abort_user_initiated_); 595 DCHECK(abort_type_ != ABORT_NONE || !abort_user_initiated_);
594 return PageLoadExtraInfo( 596 return PageLoadExtraInfo(
595 first_background_time, first_foreground_time, started_in_foreground_, 597 first_background_time, first_foreground_time, started_in_foreground_,
596 user_gesture_, commit_time_.is_null() ? GURL() : url_, time_to_commit, 598 user_gesture_, commit_time_.is_null() ? GURL() : url_, start_url_,
597 abort_type_, abort_user_initiated_, time_to_abort, num_cache_requests_, 599 time_to_commit, abort_type_, abort_user_initiated_, time_to_abort,
598 num_network_requests_, metadata_); 600 num_cache_requests_, num_network_requests_, metadata_);
599 } 601 }
600 602
601 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, 603 void PageLoadTracker::NotifyAbort(UserAbortType abort_type,
602 bool user_initiated, 604 bool user_initiated,
603 base::TimeTicks timestamp, 605 base::TimeTicks timestamp,
604 bool is_certainly_browser_timestamp) { 606 bool is_certainly_browser_timestamp) {
605 DCHECK_NE(abort_type, ABORT_NONE); 607 DCHECK_NE(abort_type, ABORT_NONE);
606 // Use UpdateAbort to update an already notified PageLoadTracker. 608 // Use UpdateAbort to update an already notified PageLoadTracker.
607 if (abort_type_ != ABORT_NONE) 609 if (abort_type_ != ABORT_NONE)
608 return; 610 return;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 content::NavigationHandle* navigation_handle) const { 1068 content::NavigationHandle* navigation_handle) const {
1067 DCHECK(navigation_handle->IsInMainFrame()); 1069 DCHECK(navigation_handle->IsInMainFrame());
1068 DCHECK(!navigation_handle->HasCommitted() || 1070 DCHECK(!navigation_handle->HasCommitted() ||
1069 !navigation_handle->IsSamePage()); 1071 !navigation_handle->IsSamePage());
1070 1072
1071 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 1073 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
1072 navigation_handle).ShouldTrack(); 1074 navigation_handle).ShouldTrack();
1073 } 1075 }
1074 1076
1075 } // namespace page_load_metrics 1077 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698