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

Side by Side Diff: chrome/browser/net/load_timing_browsertest.cc

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/location.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/single_thread_task_runner.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
18 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
20 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
23 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
24 #include "net/base/load_timing_info.h" 26 #include "net/base/load_timing_info.h"
25 #include "net/test/spawned_test_server/spawned_test_server.h" 27 #include "net/test/spawned_test_server/spawned_test_server.h"
26 #include "net/url_request/url_request_file_job.h" 28 #include "net/url_request/url_request_file_job.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void Start() override { 134 void Start() override {
133 base::TimeDelta time_to_wait; 135 base::TimeDelta time_to_wait;
134 start_time_ = base::TimeTicks::Now(); 136 start_time_ = base::TimeTicks::Now();
135 if (!load_timing_deltas_.receive_headers_end.is_null()) { 137 if (!load_timing_deltas_.receive_headers_end.is_null()) {
136 // Need to delay starting until the largest of the times has elapsed. 138 // Need to delay starting until the largest of the times has elapsed.
137 // Wait a little longer than necessary, to be on the safe side. 139 // Wait a little longer than necessary, to be on the safe side.
138 time_to_wait = load_timing_deltas_.receive_headers_end.GetDelta() + 140 time_to_wait = load_timing_deltas_.receive_headers_end.GetDelta() +
139 base::TimeDelta::FromMilliseconds(100); 141 base::TimeDelta::FromMilliseconds(100);
140 } 142 }
141 143
142 base::MessageLoop::current()->PostDelayedTask( 144 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
143 FROM_HERE, 145 FROM_HERE, base::Bind(&MockUrlRequestJobWithTiming::DelayedStart,
144 base::Bind(&MockUrlRequestJobWithTiming::DelayedStart, 146 weak_factory_.GetWeakPtr()),
145 weak_factory_.GetWeakPtr()),
146 time_to_wait); 147 time_to_wait);
147 } 148 }
148 149
149 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override { 150 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override {
150 // Make sure enough time has elapsed since start was called. If this 151 // Make sure enough time has elapsed since start was called. If this
151 // fails, the test fixture itself is flaky. 152 // fails, the test fixture itself is flaky.
152 if (!load_timing_deltas_.receive_headers_end.is_null()) { 153 if (!load_timing_deltas_.receive_headers_end.is_null()) {
153 EXPECT_LE( 154 EXPECT_LE(
154 start_time_ + load_timing_deltas_.receive_headers_end.GetDelta(), 155 start_time_ + load_timing_deltas_.receive_headers_end.GetDelta(),
155 base::TimeTicks::Now()); 156 base::TimeTicks::Now());
(...skipping 27 matching lines...) Expand all
183 // If there's an SSL start time, use connect end as the SSL end time. 184 // If there's an SSL start time, use connect end as the SSL end time.
184 // The NavigationTiming API does not have a corresponding field, and there's 185 // The NavigationTiming API does not have a corresponding field, and there's
185 // no need to test the case when the values are both non-NULL and different. 186 // no need to test the case when the values are both non-NULL and different.
186 if (!load_timing_deltas_.ssl_start.is_null()) { 187 if (!load_timing_deltas_.ssl_start.is_null()) {
187 load_timing_info->connect_timing.ssl_end = 188 load_timing_info->connect_timing.ssl_end =
188 load_timing_info->connect_timing.connect_end; 189 load_timing_info->connect_timing.connect_end;
189 } 190 }
190 191
191 load_timing_info->send_start = 192 load_timing_info->send_start =
192 load_timing_deltas_.send_start.ToTimeTicks(start_time_); 193 load_timing_deltas_.send_start.ToTimeTicks(start_time_);
193 load_timing_info->send_end= 194 load_timing_info->send_end =
194 load_timing_deltas_.send_end.ToTimeTicks(start_time_); 195 load_timing_deltas_.send_end.ToTimeTicks(start_time_);
195 load_timing_info->receive_headers_end = 196 load_timing_info->receive_headers_end =
196 load_timing_deltas_.receive_headers_end.ToTimeTicks(start_time_); 197 load_timing_deltas_.receive_headers_end.ToTimeTicks(start_time_);
197 } 198 }
198 199
199 private: 200 private:
200 // Parent class is reference counted, so need to have a private destructor. 201 // Parent class is reference counted, so need to have a private destructor.
201 ~MockUrlRequestJobWithTiming() override {} 202 ~MockUrlRequestJobWithTiming() override {}
202 203
203 void DelayedStart() { 204 void DelayedStart() {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 navigation_deltas.send_start.GetDelta()); 588 navigation_deltas.send_start.GetDelta());
588 // The only times that are guaranteed to be distinct are send_start and 589 // The only times that are guaranteed to be distinct are send_start and
589 // received_headers_end. 590 // received_headers_end.
590 EXPECT_LT(navigation_deltas.send_start.GetDelta(), 591 EXPECT_LT(navigation_deltas.send_start.GetDelta(),
591 navigation_deltas.receive_headers_end.GetDelta()); 592 navigation_deltas.receive_headers_end.GetDelta());
592 593
593 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); 594 EXPECT_TRUE(navigation_deltas.ssl_start.is_null());
594 } 595 }
595 596
596 } // namespace 597 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/metrics/thread_watcher.cc ('k') | chrome/browser/password_manager/password_store_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698