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 */, |
61 0 /* original_network_content_length */}, | 61 nullptr /* data_reduction_proxy_data */}, |
62 // Uncached non-proxied request. | 62 // Uncached non-proxied request. |
63 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 63 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
64 false /* data_reduction_proxy_used*/, | 64 1024 * 40 /* original_network_content_length */, |
65 1024 * 40 /* original_network_content_length */}, | 65 nullptr /* data_reduction_proxy_data */}, |
66 // Uncached proxied request with .1 compression ratio. | 66 // Uncached proxied request with .1 compression ratio. |
67 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 67 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
68 false /* data_reduction_proxy_used*/, | 68 1024 * 40 /* original_network_content_length */, |
69 1024 * 40 /* original_network_content_length */}, | 69 nullptr /* data_reduction_proxy_data */}, |
70 // Uncached proxied request with .5 compression ratio. | 70 // Uncached proxied request with .5 compression ratio. |
71 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 71 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
72 false /* data_reduction_proxy_used*/, | 72 1024 * 40 /* original_network_content_length */, |
73 1024 * 40 /* original_network_content_length */}, | 73 nullptr /* data_reduction_proxy_data */}, |
74 }; | 74 }; |
75 | 75 |
76 for (auto request : resources) { | 76 for (const auto& request : resources) { |
77 SimulateLoadedResource(request); | 77 SimulateLoadedResource(request); |
78 if (!request.was_cached) { | 78 if (!request.was_cached) { |
79 network_bytes_ += request.raw_body_bytes; | 79 network_bytes_ += request.raw_body_bytes; |
80 } else { | 80 } else { |
81 cache_bytes_ += request.raw_body_bytes; | 81 cache_bytes_ += request.raw_body_bytes; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 if (simulate_app_background) { | 85 if (simulate_app_background) { |
86 // The histograms should be logged when the app is backgrounded. | 86 // 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 */, | 142 SimulatePageLoad(false /* simulate_play_media */, |
143 false /* simulate_app_background */); | 143 false /* simulate_app_background */); |
144 | 144 |
145 histogram_tester().ExpectTotalCount( | 145 histogram_tester().ExpectTotalCount( |
146 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); | 146 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); |
147 histogram_tester().ExpectTotalCount( | 147 histogram_tester().ExpectTotalCount( |
148 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); | 148 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); |
149 histogram_tester().ExpectTotalCount( | 149 histogram_tester().ExpectTotalCount( |
150 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); | 150 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); |
151 } | 151 } |
OLD | NEW |