| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::ExtraRequestInfo 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 false /* data_reduction_proxy_used*/, | 75 0 /* original_network_content_length */, nullptr}, |
| 76 0 /* original_network_content_length */}, | |
| 77 // Uncached non-proxied request. | 76 // Uncached non-proxied request. |
| 78 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 77 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
| 79 false /* data_reduction_proxy_used*/, | 78 1024 * 40 /* original_network_content_length */, nullptr}, |
| 80 1024 * 40 /* original_network_content_length */}, | |
| 81 // Uncached proxied request with .1 compression ratio. | 79 // Uncached proxied request with .1 compression ratio. |
| 82 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 80 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
| 83 false /* data_reduction_proxy_used*/, | 81 1024 * 40 /* original_network_content_length */, nullptr}, |
| 84 1024 * 40 /* original_network_content_length */}, | |
| 85 // Uncached proxied request with .5 compression ratio. | 82 // Uncached proxied request with .5 compression ratio. |
| 86 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 83 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
| 87 false /* data_reduction_proxy_used*/, | 84 1024 * 40 /* original_network_content_length */, nullptr}, |
| 88 1024 * 40 /* original_network_content_length */}, | |
| 89 }; | 85 }; |
| 90 | 86 |
| 91 for (auto request : resources) { | 87 for (const auto& request : resources) { |
| 92 SimulateLoadedResource(request); | 88 SimulateLoadedResource(request); |
| 93 if (!request.was_cached) { | 89 if (!request.was_cached) { |
| 94 network_bytes_ += request.raw_body_bytes; | 90 network_bytes_ += request.raw_body_bytes; |
| 95 } else { | 91 } else { |
| 96 cache_bytes_ += request.raw_body_bytes; | 92 cache_bytes_ += request.raw_body_bytes; |
| 97 } | 93 } |
| 98 } | 94 } |
| 99 | 95 |
| 100 if (simulate_app_background) { | 96 if (simulate_app_background) { |
| 101 // The histograms should be logged when the app is backgrounded. | 97 // The histograms should be logged when the app is backgrounded. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 histogram_tester().ExpectUniqueSample( | 149 histogram_tester().ExpectUniqueSample( |
| 154 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", | 150 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", |
| 155 static_cast<int>(network_bytes_ / 1024), 1); | 151 static_cast<int>(network_bytes_ / 1024), 1); |
| 156 histogram_tester().ExpectUniqueSample( | 152 histogram_tester().ExpectUniqueSample( |
| 157 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", | 153 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", |
| 158 static_cast<int>(cache_bytes_ / 1024), 1); | 154 static_cast<int>(cache_bytes_ / 1024), 1); |
| 159 histogram_tester().ExpectUniqueSample( | 155 histogram_tester().ExpectUniqueSample( |
| 160 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", | 156 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", |
| 161 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); | 157 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); |
| 162 } | 158 } |
| OLD | NEW |