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