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" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "chrome/browser/page_load_metrics/page_load_metrics_embedder_interface.
h" | 12 #include "chrome/browser/page_load_metrics/page_load_metrics_embedder_interface.
h" |
13 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 13 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
14 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" | 14 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
15 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
18 #include "content/public/test/web_contents_tester.h" | 19 #include "content/public/test/web_contents_tester.h" |
19 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
20 | 21 |
21 namespace page_load_metrics { | 22 namespace page_load_metrics { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( | 132 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( |
132 const PageLoadTiming& timing, | 133 const PageLoadTiming& timing, |
133 const PageLoadMetadata& metadata) { | 134 const PageLoadMetadata& metadata) { |
134 observer_->OnMessageReceived(PageLoadMetricsMsg_TimingUpdated( | 135 observer_->OnMessageReceived(PageLoadMetricsMsg_TimingUpdated( |
135 observer_->routing_id(), timing, metadata), | 136 observer_->routing_id(), timing, metadata), |
136 web_contents()->GetMainFrame()); | 137 web_contents()->GetMainFrame()); |
137 } | 138 } |
138 | 139 |
139 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( | 140 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( |
140 const ExtraRequestInfo& info) { | 141 const ExtraRequestInfo& info) { |
141 observer_->OnRequestComplete( | 142 observer_->OnRequestComplete(content::GlobalRequestID(), |
142 content::GlobalRequestID(), content::RESOURCE_TYPE_SCRIPT, | 143 content::RESOURCE_TYPE_SCRIPT, info.was_cached, |
143 info.was_cached, info.data_reduction_proxy_used, info.raw_body_bytes, | 144 info.data_reduction_proxy_data |
144 info.original_network_content_length, base::TimeTicks::Now()); | 145 ? info.data_reduction_proxy_data->DeepCopy() |
| 146 : nullptr, |
| 147 info.raw_body_bytes, |
| 148 info.original_network_content_length, |
| 149 base::TimeTicks::Now()); |
145 } | 150 } |
146 | 151 |
147 void PageLoadMetricsObserverTestHarness::SimulateInputEvent( | 152 void PageLoadMetricsObserverTestHarness::SimulateInputEvent( |
148 const blink::WebInputEvent& event) { | 153 const blink::WebInputEvent& event) { |
149 observer_->OnInputEvent(event); | 154 observer_->OnInputEvent(event); |
150 } | 155 } |
151 | 156 |
152 void PageLoadMetricsObserverTestHarness::SimulateAppEnterBackground() { | 157 void PageLoadMetricsObserverTestHarness::SimulateAppEnterBackground() { |
153 observer_->FlushMetricsOnAppEnterBackground(); | 158 observer_->FlushMetricsOnAppEnterBackground(); |
154 } | 159 } |
(...skipping 17 matching lines...) Expand all Loading... |
172 } | 177 } |
173 | 178 |
174 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( | 179 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( |
175 const GURL& url, | 180 const GURL& url, |
176 ui::PageTransition transition) { | 181 ui::PageTransition transition) { |
177 controller().LoadURL(url, content::Referrer(), transition, std::string()); | 182 controller().LoadURL(url, content::Referrer(), transition, std::string()); |
178 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 183 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
179 } | 184 } |
180 | 185 |
181 } // namespace page_load_metrics | 186 } // namespace page_load_metrics |
OLD | NEW |