Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/page_load_metrics/observers/tab_restore_page_load_metrics_observer_unittest.cc

Issue 2798953002: [PageLoadMetrics] Keep track of Ad Sizes on Pages (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
64 } 64 }
65 65
66 void SimulatePageLoad(bool is_restore, bool simulate_app_background) { 66 void SimulatePageLoad(bool is_restore, bool simulate_app_background) {
67 is_restore_ = is_restore; 67 is_restore_ = is_restore;
68 NavigateAndCommit(GURL(kDefaultTestUrl)); 68 NavigateAndCommit(GURL(kDefaultTestUrl));
69 SimulateTimingUpdate(timing_); 69 SimulateTimingUpdate(timing_);
70 70
71 // Prepare 4 resources of varying size and configurations. 71 // Prepare 4 resources of varying size and configurations.
72 page_load_metrics::ExtraRequestCompleteInfo resources[] = { 72 page_load_metrics::ExtraRequestCompleteInfo resources[] = {
73 // Cached request. 73 // Cached request.
74 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 74 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/,
75 1024 * 40 /* raw_body_bytes */,
75 0 /* original_network_content_length */, 76 0 /* original_network_content_length */,
76 nullptr /* data_reduction_proxy_data */, 77 nullptr /* data_reduction_proxy_data */,
77 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 78 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
78 // Uncached non-proxied request. 79 // Uncached non-proxied request.
79 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 80 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/,
81 1024 * 40 /* raw_body_bytes */,
80 1024 * 40 /* original_network_content_length */, 82 1024 * 40 /* original_network_content_length */,
81 nullptr /* data_reduction_proxy_data */, 83 nullptr /* data_reduction_proxy_data */,
82 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 84 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
83 // Uncached proxied request with .1 compression ratio. 85 // Uncached proxied request with .1 compression ratio.
84 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 86 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/,
87 1024 * 40 /* raw_body_bytes */,
85 1024 * 40 /* original_network_content_length */, 88 1024 * 40 /* original_network_content_length */,
86 nullptr /* data_reduction_proxy_data */, 89 nullptr /* data_reduction_proxy_data */,
87 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 90 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
88 // Uncached proxied request with .5 compression ratio. 91 // Uncached proxied request with .5 compression ratio.
89 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 92 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/,
93 1024 * 40 /* raw_body_bytes */,
90 1024 * 40 /* original_network_content_length */, 94 1024 * 40 /* original_network_content_length */,
91 nullptr /* data_reduction_proxy_data */, 95 nullptr /* data_reduction_proxy_data */,
92 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 96 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
93 }; 97 };
94 98
95 for (const auto& request : resources) { 99 for (const auto& request : resources) {
96 SimulateLoadedResource(request); 100 SimulateLoadedResource(request);
97 if (!request.was_cached) { 101 if (!request.was_cached) {
98 network_bytes_ += request.raw_body_bytes; 102 network_bytes_ += request.raw_body_bytes;
99 } else { 103 } else {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 histogram_tester().ExpectUniqueSample( 161 histogram_tester().ExpectUniqueSample(
158 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network", 162 "PageLoad.Clients.TabRestore.Experimental.Bytes.Network",
159 static_cast<int>(network_bytes_ / 1024), 1); 163 static_cast<int>(network_bytes_ / 1024), 1);
160 histogram_tester().ExpectUniqueSample( 164 histogram_tester().ExpectUniqueSample(
161 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache", 165 "PageLoad.Clients.TabRestore.Experimental.Bytes.Cache",
162 static_cast<int>(cache_bytes_ / 1024), 1); 166 static_cast<int>(cache_bytes_ / 1024), 1);
163 histogram_tester().ExpectUniqueSample( 167 histogram_tester().ExpectUniqueSample(
164 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total", 168 "PageLoad.Clients.TabRestore.Experimental.Bytes.Total",
165 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1); 169 static_cast<int>((network_bytes_ + cache_bytes_) / 1024), 1);
166 } 170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698