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

Side by Side Diff: chrome/browser/page_load_metrics/observers/tab_restore_page_load_metrics_observer.cc

Issue 2874663005: [Page Load Metrics] Add mojom file to page load metrics. (Closed)
Patch Set: Remove unnecessary variable Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/observers/tab_restore_page_load_metri cs_observer.h" 5 #include "chrome/browser/page_load_metrics/observers/tab_restore_page_load_metri cs_observer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 10 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 extra_request_complete_info) { 44 extra_request_complete_info) {
45 if (extra_request_complete_info.was_cached) { 45 if (extra_request_complete_info.was_cached) {
46 cache_bytes_ += extra_request_complete_info.raw_body_bytes; 46 cache_bytes_ += extra_request_complete_info.raw_body_bytes;
47 } else { 47 } else {
48 network_bytes_ += extra_request_complete_info.raw_body_bytes; 48 network_bytes_ += extra_request_complete_info.raw_body_bytes;
49 } 49 }
50 } 50 }
51 51
52 page_load_metrics::PageLoadMetricsObserver::ObservePolicy 52 page_load_metrics::PageLoadMetricsObserver::ObservePolicy
53 TabRestorePageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( 53 TabRestorePageLoadMetricsObserver::FlushMetricsOnAppEnterBackground(
54 const page_load_metrics::PageLoadTiming& timing, 54 const page_load_metrics::mojom::PageLoadTiming& timing,
55 const page_load_metrics::PageLoadExtraInfo& info) { 55 const page_load_metrics::PageLoadExtraInfo& info) {
56 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the 56 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the
57 // app is about to be backgrounded, as part of the Activity.onPause() 57 // app is about to be backgrounded, as part of the Activity.onPause()
58 // flow. After this method is invoked, Chrome may be killed without further 58 // flow. After this method is invoked, Chrome may be killed without further
59 // notification, so we record final metrics collected up to this point. 59 // notification, so we record final metrics collected up to this point.
60 if (info.did_commit) { 60 if (info.did_commit) {
61 RecordByteHistograms(); 61 RecordByteHistograms();
62 } 62 }
63 return STOP_OBSERVING; 63 return STOP_OBSERVING;
64 } 64 }
65 65
66 void TabRestorePageLoadMetricsObserver::OnComplete( 66 void TabRestorePageLoadMetricsObserver::OnComplete(
67 const page_load_metrics::PageLoadTiming& timing, 67 const page_load_metrics::mojom::PageLoadTiming& timing,
68 const page_load_metrics::PageLoadExtraInfo& info) { 68 const page_load_metrics::PageLoadExtraInfo& info) {
69 RecordByteHistograms(); 69 RecordByteHistograms();
70 } 70 }
71 71
72 void TabRestorePageLoadMetricsObserver::RecordByteHistograms() { 72 void TabRestorePageLoadMetricsObserver::RecordByteHistograms() {
73 PAGE_BYTES_HISTOGRAM(kHistogramNetworkBytes, network_bytes_); 73 PAGE_BYTES_HISTOGRAM(kHistogramNetworkBytes, network_bytes_);
74 PAGE_BYTES_HISTOGRAM(kHistogramCacheBytes, cache_bytes_); 74 PAGE_BYTES_HISTOGRAM(kHistogramCacheBytes, cache_bytes_);
75 PAGE_BYTES_HISTOGRAM(kHistogramTotalBytes, network_bytes_ + cache_bytes_); 75 PAGE_BYTES_HISTOGRAM(kHistogramTotalBytes, network_bytes_ + cache_bytes_);
76 } 76 }
77 77
78 bool TabRestorePageLoadMetricsObserver::IsTabRestore( 78 bool TabRestorePageLoadMetricsObserver::IsTabRestore(
79 content::NavigationHandle* navigation_handle) { 79 content::NavigationHandle* navigation_handle) {
80 // Only count restored tabs, and eliminate forward-back navigations, as 80 // Only count restored tabs, and eliminate forward-back navigations, as
81 // restored tab history is considered a restored navigation until they are 81 // restored tab history is considered a restored navigation until they are
82 // loaded the first time. 82 // loaded the first time.
83 return navigation_handle->GetRestoreType() != content::RestoreType::NONE && 83 return navigation_handle->GetRestoreType() != content::RestoreType::NONE &&
84 !(navigation_handle->GetPageTransition() & 84 !(navigation_handle->GetPageTransition() &
85 ui::PAGE_TRANSITION_FORWARD_BACK); 85 ui::PAGE_TRANSITION_FORWARD_BACK);
86 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698