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

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

Issue 2560043004: [PageLoadMetrics] Record bytes usage per page (Closed)
Patch Set: Add test Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/page_load_tracker.h" 5 #include "chrome/browser/page_load_metrics/page_load_tracker.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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 : did_stop_tracking_(false), 293 : did_stop_tracking_(false),
294 app_entered_background_(false), 294 app_entered_background_(false),
295 navigation_start_(navigation_handle->NavigationStart()), 295 navigation_start_(navigation_handle->NavigationStart()),
296 start_url_(navigation_handle->GetURL()), 296 start_url_(navigation_handle->GetURL()),
297 abort_type_(ABORT_NONE), 297 abort_type_(ABORT_NONE),
298 abort_user_initiated_info_(UserInitiatedInfo::NotUserInitiated()), 298 abort_user_initiated_info_(UserInitiatedInfo::NotUserInitiated()),
299 started_in_foreground_(in_foreground), 299 started_in_foreground_(in_foreground),
300 page_transition_(navigation_handle->GetPageTransition()), 300 page_transition_(navigation_handle->GetPageTransition()),
301 num_cache_requests_(0), 301 num_cache_requests_(0),
302 num_network_requests_(0), 302 num_network_requests_(0),
303 cache_bytes_(0),
304 network_bytes_(0),
303 user_initiated_info_(user_initiated_info), 305 user_initiated_info_(user_initiated_info),
304 aborted_chain_size_(aborted_chain_size), 306 aborted_chain_size_(aborted_chain_size),
305 aborted_chain_size_same_url_(aborted_chain_size_same_url), 307 aborted_chain_size_same_url_(aborted_chain_size_same_url),
306 embedder_interface_(embedder_interface) { 308 embedder_interface_(embedder_interface) {
307 DCHECK(!navigation_handle->HasCommitted()); 309 DCHECK(!navigation_handle->HasCommitted());
308 if (embedder_interface_->IsPrerendering( 310 if (embedder_interface_->IsPrerendering(
309 navigation_handle->GetWebContents())) { 311 navigation_handle->GetWebContents())) {
310 DCHECK(!started_in_foreground_); 312 DCHECK(!started_in_foreground_);
311 // For the time being, we do not track prerenders. See crbug.com/648338 for 313 // For the time being, we do not track prerenders. See crbug.com/648338 for
312 // details. 314 // details.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); 524 const PageLoadExtraInfo info = ComputePageLoadExtraInfo();
523 for (const auto& observer : observers_) { 525 for (const auto& observer : observers_) {
524 DispatchObserverTimingCallbacks(observer.get(), last_timing, new_timing, 526 DispatchObserverTimingCallbacks(observer.get(), last_timing, new_timing,
525 last_metadata, info); 527 last_metadata, info);
526 } 528 }
527 return true; 529 return true;
528 } 530 }
529 return false; 531 return false;
530 } 532 }
531 533
532 void PageLoadTracker::OnLoadedSubresource(bool was_cached) { 534 void PageLoadTracker::OnLoadedSubresource(bool was_cached,
535 int64_t raw_body_bytes) {
533 if (was_cached) { 536 if (was_cached) {
534 ++num_cache_requests_; 537 ++num_cache_requests_;
538 cache_bytes_ += raw_body_bytes;
535 } else { 539 } else {
536 ++num_network_requests_; 540 ++num_network_requests_;
541 network_bytes_ += raw_body_bytes;
537 } 542 }
538 } 543 }
539 544
540 void PageLoadTracker::StopTracking() { 545 void PageLoadTracker::StopTracking() {
541 did_stop_tracking_ = true; 546 did_stop_tracking_ = true;
542 observers_.clear(); 547 observers_.clear();
543 } 548 }
544 549
545 void PageLoadTracker::AddObserver( 550 void PageLoadTracker::AddObserver(
546 std::unique_ptr<PageLoadMetricsObserver> observer) { 551 std::unique_ptr<PageLoadMetricsObserver> observer) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // abort_type_ == ABORT_NONE implies abort_user_initiated_info_ is not user 604 // abort_type_ == ABORT_NONE implies abort_user_initiated_info_ is not user
600 // initiated. 605 // initiated.
601 DCHECK(abort_type_ != ABORT_NONE || 606 DCHECK(abort_type_ != ABORT_NONE ||
602 (!abort_user_initiated_info_.browser_initiated && 607 (!abort_user_initiated_info_.browser_initiated &&
603 !abort_user_initiated_info_.user_gesture && 608 !abort_user_initiated_info_.user_gesture &&
604 !abort_user_initiated_info_.user_input_event)); 609 !abort_user_initiated_info_.user_input_event));
605 return PageLoadExtraInfo( 610 return PageLoadExtraInfo(
606 first_background_time, first_foreground_time, started_in_foreground_, 611 first_background_time, first_foreground_time, started_in_foreground_,
607 user_initiated_info_, committed_url_, start_url_, abort_type_, 612 user_initiated_info_, committed_url_, start_url_, abort_type_,
608 abort_user_initiated_info_, time_to_abort, num_cache_requests_, 613 abort_user_initiated_info_, time_to_abort, num_cache_requests_,
609 num_network_requests_, metadata_); 614 num_network_requests_, cache_bytes_, network_bytes_, metadata_);
610 } 615 }
611 616
612 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, 617 void PageLoadTracker::NotifyAbort(UserAbortType abort_type,
613 UserInitiatedInfo user_initiated_info, 618 UserInitiatedInfo user_initiated_info,
614 base::TimeTicks timestamp, 619 base::TimeTicks timestamp,
615 bool is_certainly_browser_timestamp) { 620 bool is_certainly_browser_timestamp) {
616 DCHECK_NE(abort_type, ABORT_NONE); 621 DCHECK_NE(abort_type, ABORT_NONE);
617 // Use UpdateAbort to update an already notified PageLoadTracker. 622 // Use UpdateAbort to update an already notified PageLoadTracker.
618 if (abort_type_ != ABORT_NONE) 623 if (abort_type_ != ABORT_NONE)
619 return; 624 return;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 // user initiated. 689 // user initiated.
685 if (abort_type != ABORT_CLIENT_REDIRECT) 690 if (abort_type != ABORT_CLIENT_REDIRECT)
686 abort_user_initiated_info_ = user_initiated_info; 691 abort_user_initiated_info_ = user_initiated_info;
687 692
688 if (is_certainly_browser_timestamp) { 693 if (is_certainly_browser_timestamp) {
689 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); 694 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_);
690 } 695 }
691 } 696 }
692 697
693 } // namespace page_load_metrics 698 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698