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

Side by Side Diff: chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.cc

Issue 2901383002: Buffer cross frame paint timing updates. (Closed)
Patch Set: fix android build Created 3 years, 6 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/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 20 matching lines...) Expand all
31 : test_(test) {} 31 : test_(test) {}
32 32
33 bool IsNewTabPageUrl(const GURL& url) override { return false; } 33 bool IsNewTabPageUrl(const GURL& url) override { return false; }
34 34
35 // Forward the registration logic to the test class so that derived classes 35 // Forward the registration logic to the test class so that derived classes
36 // can override the logic there without depending on the embedder interface. 36 // can override the logic there without depending on the embedder interface.
37 void RegisterObservers(PageLoadTracker* tracker) override { 37 void RegisterObservers(PageLoadTracker* tracker) override {
38 test_->RegisterObservers(tracker); 38 test_->RegisterObservers(tracker);
39 } 39 }
40 40
41 std::unique_ptr<base::Timer> CreateTimer() override {
42 std::unique_ptr<PageLoadMetricsObserverTestHarness::WeakMockTimer> timer =
43 base::MakeUnique<PageLoadMetricsObserverTestHarness::WeakMockTimer>();
44 test_->SetMostRecentTimer(timer->AsWeakPtr());
45 return std::move(timer);
46 }
47
41 private: 48 private:
42 PageLoadMetricsObserverTestHarness* test_; 49 PageLoadMetricsObserverTestHarness* test_;
43 50
44 DISALLOW_COPY_AND_ASSIGN(TestPageLoadMetricsEmbedderInterface); 51 DISALLOW_COPY_AND_ASSIGN(TestPageLoadMetricsEmbedderInterface);
45 }; 52 };
46 53
47 } // namespace 54 } // namespace
48 55
49 PageLoadMetricsObserverTestHarness::PageLoadMetricsObserverTestHarness() 56 PageLoadMetricsObserverTestHarness::PageLoadMetricsObserverTestHarness()
50 : ChromeRenderViewHostTestHarness() {} 57 : ChromeRenderViewHostTestHarness() {}
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 146
140 void PageLoadMetricsObserverTestHarness::SimulateTimingUpdate( 147 void PageLoadMetricsObserverTestHarness::SimulateTimingUpdate(
141 const mojom::PageLoadTiming& timing) { 148 const mojom::PageLoadTiming& timing) {
142 SimulateTimingAndMetadataUpdate(timing, mojom::PageLoadMetadata()); 149 SimulateTimingAndMetadataUpdate(timing, mojom::PageLoadMetadata());
143 } 150 }
144 151
145 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( 152 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate(
146 const mojom::PageLoadTiming& timing, 153 const mojom::PageLoadTiming& timing,
147 const mojom::PageLoadMetadata& metadata) { 154 const mojom::PageLoadMetadata& metadata) {
148 observer_->OnTimingUpdated(web_contents()->GetMainFrame(), timing, metadata); 155 observer_->OnTimingUpdated(web_contents()->GetMainFrame(), timing, metadata);
156 // If sending the timing update caused the PageLoadMetricsUpdateDispatcher to
157 // schedule a buffering timer, then fire it now so metrics are dispatched to
158 // observers.
159 base::MockTimer* mock_timer = GetMostRecentTimer();
160 if (mock_timer && mock_timer->IsRunning())
161 mock_timer->Fire();
149 } 162 }
150 163
151 void PageLoadMetricsObserverTestHarness::SimulateStartedResource( 164 void PageLoadMetricsObserverTestHarness::SimulateStartedResource(
152 const ExtraRequestStartInfo& info) { 165 const ExtraRequestStartInfo& info) {
153 observer_->OnRequestStarted(content::GlobalRequestID(), info.resource_type, 166 observer_->OnRequestStarted(content::GlobalRequestID(), info.resource_type,
154 base::TimeTicks::Now()); 167 base::TimeTicks::Now());
155 } 168 }
156 169
157 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( 170 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource(
158 const ExtraRequestCompleteInfo& info) { 171 const ExtraRequestCompleteInfo& info) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 212 }
200 213
201 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( 214 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit(
202 const GURL& url, 215 const GURL& url,
203 ui::PageTransition transition) { 216 ui::PageTransition transition) {
204 controller().LoadURL(url, content::Referrer(), transition, std::string()); 217 controller().LoadURL(url, content::Referrer(), transition, std::string());
205 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); 218 content::WebContentsTester::For(web_contents())->CommitPendingNavigation();
206 } 219 }
207 220
208 } // namespace page_load_metrics 221 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698