OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 34 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
35 TabRestorePageLoadMetricsObserver::OnStart( | 35 TabRestorePageLoadMetricsObserver::OnStart( |
36 content::NavigationHandle* navigation_handle, | 36 content::NavigationHandle* navigation_handle, |
37 const GURL& currently_committed_url, | 37 const GURL& currently_committed_url, |
38 bool started_in_foreground) { | 38 bool started_in_foreground) { |
39 return IsTabRestore(navigation_handle) ? CONTINUE_OBSERVING : STOP_OBSERVING; | 39 return IsTabRestore(navigation_handle) ? CONTINUE_OBSERVING : STOP_OBSERVING; |
40 } | 40 } |
41 | 41 |
42 void TabRestorePageLoadMetricsObserver::OnLoadedResource( | 42 void TabRestorePageLoadMetricsObserver::OnLoadedResource( |
43 const page_load_metrics::ExtraRequestInfo& extra_request_info) { | 43 const page_load_metrics::ExtraRequestCompleteInfo& |
44 if (extra_request_info.was_cached) { | 44 extra_request_complete_info) { |
45 cache_bytes_ += extra_request_info.raw_body_bytes; | 45 if (extra_request_complete_info.was_cached) { |
| 46 cache_bytes_ += extra_request_complete_info.raw_body_bytes; |
46 } else { | 47 } else { |
47 network_bytes_ += extra_request_info.raw_body_bytes; | 48 network_bytes_ += extra_request_complete_info.raw_body_bytes; |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 52 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
52 TabRestorePageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( | 53 TabRestorePageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( |
53 const page_load_metrics::PageLoadTiming& timing, | 54 const page_load_metrics::PageLoadTiming& timing, |
54 const page_load_metrics::PageLoadExtraInfo& info) { | 55 const page_load_metrics::PageLoadExtraInfo& info) { |
55 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the | 56 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the |
56 // 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() |
57 // 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 |
(...skipping 18 matching lines...) Expand all Loading... |
76 | 77 |
77 bool TabRestorePageLoadMetricsObserver::IsTabRestore( | 78 bool TabRestorePageLoadMetricsObserver::IsTabRestore( |
78 content::NavigationHandle* navigation_handle) { | 79 content::NavigationHandle* navigation_handle) { |
79 // Only count restored tabs, and eliminate forward-back navigations, as | 80 // Only count restored tabs, and eliminate forward-back navigations, as |
80 // restored tab history is considered a restored navigation until they are | 81 // restored tab history is considered a restored navigation until they are |
81 // loaded the first time. | 82 // loaded the first time. |
82 return navigation_handle->GetRestoreType() != content::RestoreType::NONE && | 83 return navigation_handle->GetRestoreType() != content::RestoreType::NONE && |
83 !(navigation_handle->GetPageTransition() & | 84 !(navigation_handle->GetPageTransition() & |
84 ui::PAGE_TRANSITION_FORWARD_BACK); | 85 ui::PAGE_TRANSITION_FORWARD_BACK); |
85 } | 86 } |
OLD | NEW |