OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/media_page_load_metrics_obs
erver.h" | 5 #include "chrome/browser/page_load_metrics/observers/media_page_load_metrics_obs
erver.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 if (simulate_play_media) | 51 if (simulate_play_media) |
52 SimulateMediaPlayed(); | 52 SimulateMediaPlayed(); |
53 | 53 |
54 SimulateTimingUpdate(timing_); | 54 SimulateTimingUpdate(timing_); |
55 | 55 |
56 // Prepare 4 resources of varying size and configurations. | 56 // Prepare 4 resources of varying size and configurations. |
57 page_load_metrics::ExtraRequestInfo resources[] = { | 57 page_load_metrics::ExtraRequestInfo resources[] = { |
58 // Cached request. | 58 // Cached request. |
59 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 59 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
60 false /* data_reduction_proxy_used*/, | 60 0 /* original_network_content_length */, nullptr}, |
61 0 /* original_network_content_length */}, | |
62 // Uncached non-proxied request. | 61 // Uncached non-proxied request. |
63 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 62 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
64 false /* data_reduction_proxy_used*/, | 63 1024 * 40 /* original_network_content_length */, nullptr}, |
65 1024 * 40 /* original_network_content_length */}, | |
66 // Uncached proxied request with .1 compression ratio. | 64 // Uncached proxied request with .1 compression ratio. |
67 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 65 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
68 false /* data_reduction_proxy_used*/, | 66 1024 * 40 /* original_network_content_length */, nullptr}, |
69 1024 * 40 /* original_network_content_length */}, | |
70 // Uncached proxied request with .5 compression ratio. | 67 // Uncached proxied request with .5 compression ratio. |
71 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 68 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
72 false /* data_reduction_proxy_used*/, | 69 1024 * 40 /* original_network_content_length */, nullptr}, |
73 1024 * 40 /* original_network_content_length */}, | |
74 }; | 70 }; |
75 | 71 |
76 for (auto request : resources) { | 72 for (const auto& request : resources) { |
77 SimulateLoadedResource(request); | 73 SimulateLoadedResource(request); |
78 if (!request.was_cached) { | 74 if (!request.was_cached) { |
79 network_bytes_ += request.raw_body_bytes; | 75 network_bytes_ += request.raw_body_bytes; |
80 } else { | 76 } else { |
81 cache_bytes_ += request.raw_body_bytes; | 77 cache_bytes_ += request.raw_body_bytes; |
82 } | 78 } |
83 } | 79 } |
84 | 80 |
85 if (simulate_app_background) { | 81 if (simulate_app_background) { |
86 // The histograms should be logged when the app is backgrounded. | 82 // The histograms should be logged when the app is backgrounded. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 SimulatePageLoad(false /* simulate_play_media */, | 138 SimulatePageLoad(false /* simulate_play_media */, |
143 false /* simulate_app_background */); | 139 false /* simulate_app_background */); |
144 | 140 |
145 histogram_tester().ExpectTotalCount( | 141 histogram_tester().ExpectTotalCount( |
146 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); | 142 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); |
147 histogram_tester().ExpectTotalCount( | 143 histogram_tester().ExpectTotalCount( |
148 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); | 144 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); |
149 histogram_tester().ExpectTotalCount( | 145 histogram_tester().ExpectTotalCount( |
150 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); | 146 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); |
151 } | 147 } |
OLD | NEW |