OLD | NEW |
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/location.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/task_scheduler/post_task.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
23 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
26 #include "net/base/load_timing_info.h" | 26 #include "net/base/load_timing_info.h" |
27 #include "net/test/spawned_test_server/spawned_test_server.h" | 27 #include "net/test/spawned_test_server/spawned_test_server.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 // Mock UrlRequestJob that returns the contents of a specified file and | 117 // Mock UrlRequestJob that returns the contents of a specified file and |
118 // provides the specified load timing information when queried. | 118 // provides the specified load timing information when queried. |
119 class MockUrlRequestJobWithTiming : public net::URLRequestFileJob { | 119 class MockUrlRequestJobWithTiming : public net::URLRequestFileJob { |
120 public: | 120 public: |
121 MockUrlRequestJobWithTiming(net::URLRequest* request, | 121 MockUrlRequestJobWithTiming(net::URLRequest* request, |
122 net::NetworkDelegate* network_delegate, | 122 net::NetworkDelegate* network_delegate, |
123 const base::FilePath& path, | 123 const base::FilePath& path, |
124 const TimingDeltas& load_timing_deltas) | 124 const TimingDeltas& load_timing_deltas) |
125 : net::URLRequestFileJob( | 125 : net::URLRequestFileJob( |
126 request, network_delegate, path, | 126 request, |
127 content::BrowserThread::GetBlockingPool()-> | 127 network_delegate, |
128 GetTaskRunnerWithShutdownBehavior( | 128 path, |
129 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), | 129 base::CreateTaskRunnerWithTraits( |
| 130 base::TaskTraits() |
| 131 .MayBlock() |
| 132 .WithPriority(base::TaskPriority::BACKGROUND) |
| 133 .WithShutdownBehavior( |
| 134 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))), |
130 load_timing_deltas_(load_timing_deltas), | 135 load_timing_deltas_(load_timing_deltas), |
131 weak_factory_(this) {} | 136 weak_factory_(this) {} |
132 | 137 |
133 // net::URLRequestFileJob implementation: | 138 // net::URLRequestFileJob implementation: |
134 void Start() override { | 139 void Start() override { |
135 base::TimeDelta time_to_wait; | 140 base::TimeDelta time_to_wait; |
136 start_time_ = base::TimeTicks::Now(); | 141 start_time_ = base::TimeTicks::Now(); |
137 if (!load_timing_deltas_.receive_headers_end.is_null()) { | 142 if (!load_timing_deltas_.receive_headers_end.is_null()) { |
138 // Need to delay starting until the largest of the times has elapsed. | 143 // Need to delay starting until the largest of the times has elapsed. |
139 // Wait a little longer than necessary, to be on the safe side. | 144 // Wait a little longer than necessary, to be on the safe side. |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 navigation_deltas.send_start.GetDelta()); | 594 navigation_deltas.send_start.GetDelta()); |
590 // The only times that are guaranteed to be distinct are send_start and | 595 // The only times that are guaranteed to be distinct are send_start and |
591 // received_headers_end. | 596 // received_headers_end. |
592 EXPECT_LT(navigation_deltas.send_start.GetDelta(), | 597 EXPECT_LT(navigation_deltas.send_start.GetDelta(), |
593 navigation_deltas.receive_headers_end.GetDelta()); | 598 navigation_deltas.receive_headers_end.GetDelta()); |
594 | 599 |
595 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); | 600 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); |
596 } | 601 } |
597 | 602 |
598 } // namespace | 603 } // namespace |
OLD | NEW |