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