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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 network_bytes_ = 0; | 61 network_bytes_ = 0; |
62 cache_bytes_ = 0; | 62 cache_bytes_ = 0; |
63 } | 63 } |
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::ExtraRequestCompleteInfo 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 false /* data_reduction_proxy_used*/, |
75 0 /* original_network_content_length */}, | 75 0 /* original_network_content_length */, |
| 76 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
76 // Uncached non-proxied request. | 77 // Uncached non-proxied request. |
77 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 78 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
78 false /* data_reduction_proxy_used*/, | 79 false /* data_reduction_proxy_used*/, |
79 1024 * 40 /* original_network_content_length */}, | 80 1024 * 40 /* original_network_content_length */, |
| 81 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
80 // Uncached proxied request with .1 compression ratio. | 82 // Uncached proxied request with .1 compression ratio. |
81 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 83 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
82 false /* data_reduction_proxy_used*/, | 84 false /* data_reduction_proxy_used*/, |
83 1024 * 40 /* original_network_content_length */}, | 85 1024 * 40 /* original_network_content_length */, |
| 86 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
84 // Uncached proxied request with .5 compression ratio. | 87 // Uncached proxied request with .5 compression ratio. |
85 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 88 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
86 false /* data_reduction_proxy_used*/, | 89 false /* data_reduction_proxy_used*/, |
87 1024 * 40 /* original_network_content_length */}, | 90 1024 * 40 /* original_network_content_length */, |
| 91 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
88 }; | 92 }; |
89 | 93 |
90 for (auto request : resources) { | 94 for (auto request : resources) { |
91 SimulateLoadedResource(request); | 95 SimulateLoadedResource(request); |
92 if (!request.was_cached) { | 96 if (!request.was_cached) { |
93 network_bytes_ += request.raw_body_bytes; | 97 network_bytes_ += request.raw_body_bytes; |
94 } else { | 98 } else { |
95 cache_bytes_ += request.raw_body_bytes; | 99 cache_bytes_ += request.raw_body_bytes; |
96 } | 100 } |
97 } | 101 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 histogram_tester().ExpectUniqueSample( | 156 histogram_tester().ExpectUniqueSample( |
153 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", | 157 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", |
154 static_cast<int>(network_bytes_ / 1024), 1); | 158 static_cast<int>(network_bytes_ / 1024), 1); |
155 histogram_tester().ExpectUniqueSample( | 159 histogram_tester().ExpectUniqueSample( |
156 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", | 160 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", |
157 static_cast<int>(cache_bytes_ / 1024), 1); | 161 static_cast<int>(cache_bytes_ / 1024), 1); |
158 histogram_tester().ExpectUniqueSample( | 162 histogram_tester().ExpectUniqueSample( |
159 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", | 163 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", |
160 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); | 164 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); |
161 } | 165 } |
OLD | NEW |