OLD | NEW |
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/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 <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 void SimulatePageLoad(bool is_restore, bool simulate_app_background) { | 65 void SimulatePageLoad(bool is_restore, bool simulate_app_background) { |
66 is_restore_ = is_restore; | 66 is_restore_ = is_restore; |
67 NavigateAndCommit(GURL(kDefaultTestUrl)); | 67 NavigateAndCommit(GURL(kDefaultTestUrl)); |
68 SimulateTimingUpdate(timing_); | 68 SimulateTimingUpdate(timing_); |
69 | 69 |
70 // Prepare 4 resources of varying size and configurations. | 70 // Prepare 4 resources of varying size and configurations. |
71 page_load_metrics::ExtraRequestInfo resources[] = { | 71 page_load_metrics::ExtraRequestInfo resources[] = { |
72 // Cached request. | 72 // Cached request. |
73 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 73 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
74 false /* data_reduction_proxy_used*/, | 74 0 /* original_network_content_length */, |
75 0 /* original_network_content_length */}, | 75 nullptr /* data_reduction_proxy_data */}, |
76 // Uncached non-proxied request. | 76 // Uncached non-proxied request. |
77 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 77 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
78 false /* data_reduction_proxy_used*/, | 78 1024 * 40 /* original_network_content_length */, |
79 1024 * 40 /* original_network_content_length */}, | 79 nullptr /* data_reduction_proxy_data */}, |
80 // Uncached proxied request with .1 compression ratio. | 80 // Uncached proxied request with .1 compression ratio. |
81 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 81 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
82 false /* data_reduction_proxy_used*/, | 82 1024 * 40 /* original_network_content_length */, |
83 1024 * 40 /* original_network_content_length */}, | 83 nullptr /* data_reduction_proxy_data */}, |
84 // Uncached proxied request with .5 compression ratio. | 84 // Uncached proxied request with .5 compression ratio. |
85 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 85 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
86 false /* data_reduction_proxy_used*/, | 86 1024 * 40 /* original_network_content_length */, |
87 1024 * 40 /* original_network_content_length */}, | 87 nullptr /* data_reduction_proxy_data */}, |
88 }; | 88 }; |
89 | 89 |
90 for (auto request : resources) { | 90 for (const auto& request : resources) { |
91 SimulateLoadedResource(request); | 91 SimulateLoadedResource(request); |
92 if (!request.was_cached) { | 92 if (!request.was_cached) { |
93 network_bytes_ += request.raw_body_bytes; | 93 network_bytes_ += request.raw_body_bytes; |
94 } else { | 94 } else { |
95 cache_bytes_ += request.raw_body_bytes; | 95 cache_bytes_ += request.raw_body_bytes; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 if (simulate_app_background) { | 99 if (simulate_app_background) { |
100 // The histograms should be logged when the app is backgrounded. | 100 // The histograms should be logged when the app is backgrounded. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 histogram_tester().ExpectUniqueSample( | 152 histogram_tester().ExpectUniqueSample( |
153 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", | 153 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", |
154 static_cast<int>(network_bytes_ / 1024), 1); | 154 static_cast<int>(network_bytes_ / 1024), 1); |
155 histogram_tester().ExpectUniqueSample( | 155 histogram_tester().ExpectUniqueSample( |
156 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", | 156 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", |
157 static_cast<int>(cache_bytes_ / 1024), 1); | 157 static_cast<int>(cache_bytes_ / 1024), 1); |
158 histogram_tester().ExpectUniqueSample( | 158 histogram_tester().ExpectUniqueSample( |
159 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", | 159 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", |
160 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); | 160 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); |
161 } | 161 } |
OLD | NEW |