| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( | 144 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( |
| 144 const PageLoadTiming& timing, | 145 const PageLoadTiming& timing, |
| 145 const PageLoadMetadata& metadata) { | 146 const PageLoadMetadata& metadata) { |
| 146 observer_->OnMessageReceived(PageLoadMetricsMsg_TimingUpdated( | 147 observer_->OnMessageReceived(PageLoadMetricsMsg_TimingUpdated( |
| 147 observer_->routing_id(), timing, metadata), | 148 observer_->routing_id(), timing, metadata), |
| 148 web_contents()->GetMainFrame()); | 149 web_contents()->GetMainFrame()); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( | 152 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( |
| 152 const ExtraRequestInfo& info) { | 153 const ExtraRequestInfo& info) { |
| 153 observer_->OnRequestComplete( | 154 observer_->OnRequestComplete(content::GlobalRequestID(), |
| 154 content::GlobalRequestID(), content::RESOURCE_TYPE_SCRIPT, | 155 content::RESOURCE_TYPE_SCRIPT, info.was_cached, |
| 155 info.was_cached, info.data_reduction_proxy_used, info.raw_body_bytes, | 156 info.data_reduction_proxy_data |
| 156 info.original_network_content_length, base::TimeTicks::Now()); | 157 ? info.data_reduction_proxy_data->DeepCopy() |
| 158 : nullptr, |
| 159 info.raw_body_bytes, |
| 160 info.original_network_content_length, |
| 161 base::TimeTicks::Now()); |
| 157 } | 162 } |
| 158 | 163 |
| 159 void PageLoadMetricsObserverTestHarness::SimulateInputEvent( | 164 void PageLoadMetricsObserverTestHarness::SimulateInputEvent( |
| 160 const blink::WebInputEvent& event) { | 165 const blink::WebInputEvent& event) { |
| 161 observer_->OnInputEvent(event); | 166 observer_->OnInputEvent(event); |
| 162 } | 167 } |
| 163 | 168 |
| 164 void PageLoadMetricsObserverTestHarness::SimulateAppEnterBackground() { | 169 void PageLoadMetricsObserverTestHarness::SimulateAppEnterBackground() { |
| 165 observer_->FlushMetricsOnAppEnterBackground(); | 170 observer_->FlushMetricsOnAppEnterBackground(); |
| 166 } | 171 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 184 } | 189 } |
| 185 | 190 |
| 186 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( | 191 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( |
| 187 const GURL& url, | 192 const GURL& url, |
| 188 ui::PageTransition transition) { | 193 ui::PageTransition transition) { |
| 189 controller().LoadURL(url, content::Referrer(), transition, std::string()); | 194 controller().LoadURL(url, content::Referrer(), transition, std::string()); |
| 190 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 195 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| 191 } | 196 } |
| 192 | 197 |
| 193 } // namespace page_load_metrics | 198 } // namespace page_load_metrics |
| OLD | NEW |