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/metrics_web_contents_observer.h" | 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 content::WebContentsTester::For(web_contents()) | 160 content::WebContentsTester::For(web_contents()) |
161 ->NavigateAndCommit(GURL(url::kAboutBlankURL)); | 161 ->NavigateAndCommit(GURL(url::kAboutBlankURL)); |
162 } | 162 } |
163 | 163 |
164 void SimulateTimingUpdate(const PageLoadTiming& timing) { | 164 void SimulateTimingUpdate(const PageLoadTiming& timing) { |
165 SimulateTimingUpdate(timing, web_contents()->GetMainFrame()); | 165 SimulateTimingUpdate(timing, web_contents()->GetMainFrame()); |
166 } | 166 } |
167 | 167 |
168 void SimulateTimingUpdate(const PageLoadTiming& timing, | 168 void SimulateTimingUpdate(const PageLoadTiming& timing, |
169 content::RenderFrameHost* render_frame_host) { | 169 content::RenderFrameHost* render_frame_host) { |
170 observer_->OnTimingUpdated(render_frame_host, timing, PageLoadMetadata()); | 170 ASSERT_TRUE(observer_->OnMessageReceived( |
| 171 PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing, |
| 172 PageLoadMetadata()), |
| 173 render_frame_host)); |
171 } | 174 } |
172 | 175 |
173 void AttachObserver() { | 176 void AttachObserver() { |
174 embedder_interface_ = new TestPageLoadMetricsEmbedderInterface(); | 177 embedder_interface_ = new TestPageLoadMetricsEmbedderInterface(); |
175 // Owned by the web_contents. Tests must be careful not to call | 178 // Owned by the web_contents. Tests must be careful not to call |
176 // SimulateTimingUpdate after they call DeleteContents() without also | 179 // SimulateTimingUpdate after they call DeleteContents() without also |
177 // calling AttachObserver() again. Otherwise they will use-after-free the | 180 // calling AttachObserver() again. Otherwise they will use-after-free the |
178 // observer_. | 181 // observer_. |
179 observer_ = MetricsWebContentsObserver::CreateForWebContents( | 182 observer_ = MetricsWebContentsObserver::CreateForWebContents( |
180 web_contents(), base::WrapUnique(embedder_interface_)); | 183 web_contents(), base::WrapUnique(embedder_interface_)); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); | 666 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); |
664 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), | 667 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), |
665 completed_filtered_urls()); | 668 completed_filtered_urls()); |
666 | 669 |
667 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); | 670 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); |
668 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}), | 671 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}), |
669 completed_filtered_urls()); | 672 completed_filtered_urls()); |
670 } | 673 } |
671 | 674 |
672 } // namespace page_load_metrics | 675 } // namespace page_load_metrics |
OLD | NEW |