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