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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: update 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 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
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 ASSERT_TRUE(observer_->OnMessageReceived( 170 observer_->OnTimingUpdated(render_frame_host, timing, PageLoadMetadata());
171 PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing,
172 PageLoadMetadata()),
173 render_frame_host));
174 } 171 }
175 172
176 void AttachObserver() { 173 void AttachObserver() {
177 embedder_interface_ = new TestPageLoadMetricsEmbedderInterface(); 174 embedder_interface_ = new TestPageLoadMetricsEmbedderInterface();
178 // Owned by the web_contents. Tests must be careful not to call 175 // Owned by the web_contents. Tests must be careful not to call
179 // SimulateTimingUpdate after they call DeleteContents() without also 176 // SimulateTimingUpdate after they call DeleteContents() without also
180 // calling AttachObserver() again. Otherwise they will use-after-free the 177 // calling AttachObserver() again. Otherwise they will use-after-free the
181 // observer_. 178 // observer_.
182 observer_ = MetricsWebContentsObserver::CreateForWebContents( 179 observer_ = MetricsWebContentsObserver::CreateForWebContents(
183 web_contents(), base::WrapUnique(embedder_interface_)); 180 web_contents(), base::WrapUnique(embedder_interface_));
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); 663 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2));
667 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), 664 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}),
668 completed_filtered_urls()); 665 completed_filtered_urls());
669 666
670 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); 667 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
671 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}), 668 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}),
672 completed_filtered_urls()); 669 completed_filtered_urls());
673 } 670 }
674 671
675 } // namespace page_load_metrics 672 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698