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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 NavigateAndCommit(GURL(kDefaultTestUrl)); | 49 NavigateAndCommit(GURL(kDefaultTestUrl)); |
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::ExtraRequestCompleteInfo resources[] = { | 57 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
58 // Cached request. | 58 // Cached request. |
59 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 59 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
| 60 1024 * 40 /* raw_body_bytes */, |
60 0 /* original_network_content_length */, | 61 0 /* original_network_content_length */, |
61 nullptr /* data_reduction_proxy_data */, | 62 nullptr /* data_reduction_proxy_data */, |
62 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 63 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
63 // Uncached non-proxied request. | 64 // Uncached non-proxied request. |
64 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 65 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 66 1024 * 40 /* raw_body_bytes */, |
65 1024 * 40 /* original_network_content_length */, | 67 1024 * 40 /* original_network_content_length */, |
66 nullptr /* data_reduction_proxy_data */, | 68 nullptr /* data_reduction_proxy_data */, |
67 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 69 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
68 // Uncached proxied request with .1 compression ratio. | 70 // Uncached proxied request with .1 compression ratio. |
69 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 71 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 72 1024 * 40 /* raw_body_bytes */, |
70 1024 * 40 /* original_network_content_length */, | 73 1024 * 40 /* original_network_content_length */, |
71 nullptr /* data_reduction_proxy_data */, | 74 nullptr /* data_reduction_proxy_data */, |
72 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 75 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
73 // Uncached proxied request with .5 compression ratio. | 76 // Uncached proxied request with .5 compression ratio. |
74 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 77 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 78 1024 * 40 /* raw_body_bytes */, |
75 1024 * 40 /* original_network_content_length */, | 79 1024 * 40 /* original_network_content_length */, |
76 nullptr /* data_reduction_proxy_data */, | 80 nullptr /* data_reduction_proxy_data */, |
77 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 81 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
78 }; | 82 }; |
79 | 83 |
80 for (const auto& request : resources) { | 84 for (const auto& request : resources) { |
81 SimulateLoadedResource(request); | 85 SimulateLoadedResource(request); |
82 if (!request.was_cached) { | 86 if (!request.was_cached) { |
83 network_bytes_ += request.raw_body_bytes; | 87 network_bytes_ += request.raw_body_bytes; |
84 } else { | 88 } else { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 SimulatePageLoad(false /* simulate_play_media */, | 150 SimulatePageLoad(false /* simulate_play_media */, |
147 false /* simulate_app_background */); | 151 false /* simulate_app_background */); |
148 | 152 |
149 histogram_tester().ExpectTotalCount( | 153 histogram_tester().ExpectTotalCount( |
150 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); | 154 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); |
151 histogram_tester().ExpectTotalCount( | 155 histogram_tester().ExpectTotalCount( |
152 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); | 156 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); |
153 histogram_tester().ExpectTotalCount( | 157 histogram_tester().ExpectTotalCount( |
154 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); | 158 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); |
155 } | 159 } |
OLD | NEW |