OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/page_load_metrics_observer_
test_harness.h" | 5 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 void PageLoadMetricsObserverTestHarness::SimulateStartedResource( | 150 void PageLoadMetricsObserverTestHarness::SimulateStartedResource( |
151 const ExtraRequestStartInfo& info) { | 151 const ExtraRequestStartInfo& info) { |
152 observer_->OnRequestStarted(content::GlobalRequestID(), info.resource_type, | 152 observer_->OnRequestStarted(content::GlobalRequestID(), info.resource_type, |
153 base::TimeTicks::Now()); | 153 base::TimeTicks::Now()); |
154 } | 154 } |
155 | 155 |
156 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( | 156 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( |
157 const ExtraRequestCompleteInfo& info) { | 157 const ExtraRequestCompleteInfo& info) { |
| 158 content::ResourceType resource_type = content::RESOURCE_TYPE_SCRIPT; |
| 159 // To be able to find the resource in GetTrackerOrNullForRequest, |
| 160 // we depend on using something else instead of a MAIN_FRAME resource, |
| 161 // so pretend this resource is the "SCRIPT" type for simulated loading. |
| 162 if (info.resource_type != content::RESOURCE_TYPE_MAIN_FRAME) |
| 163 resource_type = info.resource_type; |
| 164 |
158 observer_->OnRequestComplete( | 165 observer_->OnRequestComplete( |
159 info.url, info.frame_tree_node_id, content::GlobalRequestID(), | 166 info.url, info.frame_tree_node_id, content::GlobalRequestID(), |
160 info.resource_type, info.was_cached, | 167 resource_type, info.was_cached, |
161 info.data_reduction_proxy_data | 168 info.data_reduction_proxy_data |
162 ? info.data_reduction_proxy_data->DeepCopy() | 169 ? info.data_reduction_proxy_data->DeepCopy() |
163 : nullptr, | 170 : nullptr, |
164 info.raw_body_bytes, info.original_network_content_length, | 171 info.raw_body_bytes, info.original_network_content_length, |
165 base::TimeTicks::Now()); | 172 base::TimeTicks::Now()); |
166 } | 173 } |
167 | 174 |
168 void PageLoadMetricsObserverTestHarness::SimulateInputEvent( | 175 void PageLoadMetricsObserverTestHarness::SimulateInputEvent( |
169 const blink::WebInputEvent& event) { | 176 const blink::WebInputEvent& event) { |
170 observer_->OnInputEvent(event); | 177 observer_->OnInputEvent(event); |
(...skipping 22 matching lines...) Expand all Loading... |
193 } | 200 } |
194 | 201 |
195 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( | 202 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( |
196 const GURL& url, | 203 const GURL& url, |
197 ui::PageTransition transition) { | 204 ui::PageTransition transition) { |
198 controller().LoadURL(url, content::Referrer(), transition, std::string()); | 205 controller().LoadURL(url, content::Referrer(), transition, std::string()); |
199 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 206 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
200 } | 207 } |
201 | 208 |
202 } // namespace page_load_metrics | 209 } // namespace page_load_metrics |
OLD | NEW |