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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" |
16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
23 #include "net/base/load_timing_info.h" | 24 #include "net/base/load_timing_info.h" |
24 #include "net/test/spawned_test_server/spawned_test_server.h" | 25 #include "net/test/spawned_test_server/spawned_test_server.h" |
25 #include "net/url_request/url_request_file_job.h" | 26 #include "net/url_request/url_request_file_job.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 }; | 113 }; |
113 | 114 |
114 // Mock UrlRequestJob that returns the contents of a specified file and | 115 // Mock UrlRequestJob that returns the contents of a specified file and |
115 // provides the specified load timing information when queried. | 116 // provides the specified load timing information when queried. |
116 class MockUrlRequestJobWithTiming : public net::URLRequestFileJob { | 117 class MockUrlRequestJobWithTiming : public net::URLRequestFileJob { |
117 public: | 118 public: |
118 MockUrlRequestJobWithTiming(net::URLRequest* request, | 119 MockUrlRequestJobWithTiming(net::URLRequest* request, |
119 net::NetworkDelegate* network_delegate, | 120 net::NetworkDelegate* network_delegate, |
120 const base::FilePath& path, | 121 const base::FilePath& path, |
121 const TimingDeltas& load_timing_deltas) | 122 const TimingDeltas& load_timing_deltas) |
122 : net::URLRequestFileJob(request, network_delegate, path), | 123 : net::URLRequestFileJob( |
| 124 request, network_delegate, path, |
| 125 content::BrowserThread::GetBlockingPool()-> |
| 126 GetTaskRunnerWithShutdownBehavior( |
| 127 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
123 load_timing_deltas_(load_timing_deltas), | 128 load_timing_deltas_(load_timing_deltas), |
124 weak_factory_(this) { | 129 weak_factory_(this) {} |
125 } | |
126 | 130 |
127 // net::URLRequestFileJob implementation: | 131 // net::URLRequestFileJob implementation: |
128 virtual void Start() OVERRIDE { | 132 virtual void Start() OVERRIDE { |
129 base::TimeDelta time_to_wait; | 133 base::TimeDelta time_to_wait; |
130 start_time_ = base::TimeTicks::Now(); | 134 start_time_ = base::TimeTicks::Now(); |
131 if (!load_timing_deltas_.receive_headers_end.is_null()) { | 135 if (!load_timing_deltas_.receive_headers_end.is_null()) { |
132 // Need to delay starting until the largest of the times has elapsed. | 136 // Need to delay starting until the largest of the times has elapsed. |
133 // Wait a little longer than necessary, to be on the safe side. | 137 // Wait a little longer than necessary, to be on the safe side. |
134 time_to_wait = load_timing_deltas_.receive_headers_end.GetDelta() + | 138 time_to_wait = load_timing_deltas_.receive_headers_end.GetDelta() + |
135 base::TimeDelta::FromMilliseconds(100); | 139 base::TimeDelta::FromMilliseconds(100); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 navigation_deltas.send_start.GetDelta()); | 590 navigation_deltas.send_start.GetDelta()); |
587 // The only times that are guaranteed to be distinct are send_start and | 591 // The only times that are guaranteed to be distinct are send_start and |
588 // received_headers_end. | 592 // received_headers_end. |
589 EXPECT_LT(navigation_deltas.send_start.GetDelta(), | 593 EXPECT_LT(navigation_deltas.send_start.GetDelta(), |
590 navigation_deltas.receive_headers_end.GetDelta()); | 594 navigation_deltas.receive_headers_end.GetDelta()); |
591 | 595 |
592 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); | 596 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); |
593 } | 597 } |
594 | 598 |
595 } // namespace | 599 } // namespace |
OLD | NEW |