OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // CallDelayedCallbacks. This allows the DnsProbeBrowserTest to enforce a | 75 // CallDelayedCallbacks. This allows the DnsProbeBrowserTest to enforce a |
76 // stricter ordering of events. | 76 // stricter ordering of events. |
77 class DelayingDnsProbeService : public DnsProbeService { | 77 class DelayingDnsProbeService : public DnsProbeService { |
78 public: | 78 public: |
79 DelayingDnsProbeService() {} | 79 DelayingDnsProbeService() {} |
80 | 80 |
81 virtual ~DelayingDnsProbeService() { | 81 virtual ~DelayingDnsProbeService() { |
82 EXPECT_TRUE(delayed_probes_.empty()); | 82 EXPECT_TRUE(delayed_probes_.empty()); |
83 } | 83 } |
84 | 84 |
85 virtual void ProbeDns(const ProbeCallback& callback) OVERRIDE { | 85 virtual void ProbeDns(const ProbeCallback& callback) override { |
86 delayed_probes_.push_back(callback); | 86 delayed_probes_.push_back(callback); |
87 } | 87 } |
88 | 88 |
89 void StartDelayedProbes() { | 89 void StartDelayedProbes() { |
90 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 90 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
91 | 91 |
92 std::vector<ProbeCallback> probes; | 92 std::vector<ProbeCallback> probes; |
93 probes.swap(delayed_probes_); | 93 probes.swap(delayed_probes_); |
94 | 94 |
95 for (std::vector<ProbeCallback>::const_iterator i = probes.begin(); | 95 for (std::vector<ProbeCallback>::const_iterator i = probes.begin(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DelayableURLRequestFailedJob(net::URLRequest* request, | 136 DelayableURLRequestFailedJob(net::URLRequest* request, |
137 net::NetworkDelegate* network_delegate, | 137 net::NetworkDelegate* network_delegate, |
138 int net_error, | 138 int net_error, |
139 bool should_delay, | 139 bool should_delay, |
140 const DestructionCallback& destruction_callback) | 140 const DestructionCallback& destruction_callback) |
141 : URLRequestFailedJob(request, network_delegate, net_error), | 141 : URLRequestFailedJob(request, network_delegate, net_error), |
142 should_delay_(should_delay), | 142 should_delay_(should_delay), |
143 start_delayed_(false), | 143 start_delayed_(false), |
144 destruction_callback_(destruction_callback) {} | 144 destruction_callback_(destruction_callback) {} |
145 | 145 |
146 virtual void Start() OVERRIDE { | 146 virtual void Start() override { |
147 if (should_delay_) { | 147 if (should_delay_) { |
148 DCHECK(!start_delayed_); | 148 DCHECK(!start_delayed_); |
149 start_delayed_ = true; | 149 start_delayed_ = true; |
150 return; | 150 return; |
151 } | 151 } |
152 URLRequestFailedJob::Start(); | 152 URLRequestFailedJob::Start(); |
153 } | 153 } |
154 | 154 |
155 virtual void Resume() OVERRIDE { | 155 virtual void Resume() override { |
156 DCHECK(should_delay_); | 156 DCHECK(should_delay_); |
157 should_delay_ = false; | 157 should_delay_ = false; |
158 if (start_delayed_) { | 158 if (start_delayed_) { |
159 start_delayed_ = false; | 159 start_delayed_ = false; |
160 Start(); | 160 Start(); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 private: | 164 private: |
165 virtual ~DelayableURLRequestFailedJob() { | 165 virtual ~DelayableURLRequestFailedJob() { |
(...skipping 18 matching lines...) Expand all Loading... |
184 : URLRequestMockHTTPJob( | 184 : URLRequestMockHTTPJob( |
185 request, | 185 request, |
186 network_delegate, | 186 network_delegate, |
187 file_path, | 187 file_path, |
188 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 188 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
189 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), | 189 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
190 should_delay_(should_delay), | 190 should_delay_(should_delay), |
191 start_delayed_(false), | 191 start_delayed_(false), |
192 destruction_callback_(destruction_callback) {} | 192 destruction_callback_(destruction_callback) {} |
193 | 193 |
194 virtual void Start() OVERRIDE { | 194 virtual void Start() override { |
195 if (should_delay_) { | 195 if (should_delay_) { |
196 DCHECK(!start_delayed_); | 196 DCHECK(!start_delayed_); |
197 start_delayed_ = true; | 197 start_delayed_ = true; |
198 return; | 198 return; |
199 } | 199 } |
200 URLRequestMockHTTPJob::Start(); | 200 URLRequestMockHTTPJob::Start(); |
201 } | 201 } |
202 | 202 |
203 virtual void Resume() OVERRIDE { | 203 virtual void Resume() override { |
204 DCHECK(should_delay_); | 204 DCHECK(should_delay_); |
205 should_delay_ = false; | 205 should_delay_ = false; |
206 if (start_delayed_) { | 206 if (start_delayed_) { |
207 start_delayed_ = false; | 207 start_delayed_ = false; |
208 Start(); | 208 Start(); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 private: | 212 private: |
213 virtual ~DelayableURLRequestMockHTTPJob() { | 213 virtual ~DelayableURLRequestMockHTTPJob() { |
(...skipping 21 matching lines...) Expand all Loading... |
235 base::Unretained(this))) { | 235 base::Unretained(this))) { |
236 } | 236 } |
237 | 237 |
238 virtual ~BreakableCorrectionInterceptor() { | 238 virtual ~BreakableCorrectionInterceptor() { |
239 // All delayed requests should have been resumed or cancelled by this point. | 239 // All delayed requests should have been resumed or cancelled by this point. |
240 EXPECT_TRUE(delayed_requests_.empty()); | 240 EXPECT_TRUE(delayed_requests_.empty()); |
241 } | 241 } |
242 | 242 |
243 virtual URLRequestJob* MaybeInterceptRequest( | 243 virtual URLRequestJob* MaybeInterceptRequest( |
244 URLRequest* request, | 244 URLRequest* request, |
245 NetworkDelegate* network_delegate) const OVERRIDE { | 245 NetworkDelegate* network_delegate) const override { |
246 if (net_error_ != net::OK) { | 246 if (net_error_ != net::OK) { |
247 DelayableURLRequestFailedJob* job = | 247 DelayableURLRequestFailedJob* job = |
248 new DelayableURLRequestFailedJob( | 248 new DelayableURLRequestFailedJob( |
249 request, network_delegate, net_error_, delay_requests_, | 249 request, network_delegate, net_error_, delay_requests_, |
250 on_request_destroyed_callback_); | 250 on_request_destroyed_callback_); |
251 if (delay_requests_) | 251 if (delay_requests_) |
252 delayed_requests_.insert(job); | 252 delayed_requests_.insert(job); |
253 return job; | 253 return job; |
254 } else { | 254 } else { |
255 DelayableURLRequestMockHTTPJob* job = | 255 DelayableURLRequestMockHTTPJob* job = |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 EXPECT_EQ(expected_delayed_probe_count, actual_delayed_probe_count); | 426 EXPECT_EQ(expected_delayed_probe_count, actual_delayed_probe_count); |
427 | 427 |
428 delaying_dns_probe_service_->StartDelayedProbes(); | 428 delaying_dns_probe_service_->StartDelayedProbes(); |
429 } | 429 } |
430 | 430 |
431 class DnsProbeBrowserTest : public InProcessBrowserTest { | 431 class DnsProbeBrowserTest : public InProcessBrowserTest { |
432 public: | 432 public: |
433 DnsProbeBrowserTest(); | 433 DnsProbeBrowserTest(); |
434 virtual ~DnsProbeBrowserTest(); | 434 virtual ~DnsProbeBrowserTest(); |
435 | 435 |
436 virtual void SetUpOnMainThread() OVERRIDE; | 436 virtual void SetUpOnMainThread() override; |
437 virtual void TearDownOnMainThread() OVERRIDE; | 437 virtual void TearDownOnMainThread() override; |
438 | 438 |
439 protected: | 439 protected: |
440 // Sets the browser object that other methods apply to, and that has the | 440 // Sets the browser object that other methods apply to, and that has the |
441 // DnsProbeStatus messages of its currently active tab monitored. | 441 // DnsProbeStatus messages of its currently active tab monitored. |
442 void SetActiveBrowser(Browser* browser); | 442 void SetActiveBrowser(Browser* browser); |
443 | 443 |
444 void SetCorrectionServiceBroken(bool broken); | 444 void SetCorrectionServiceBroken(bool broken); |
445 void SetCorrectionServiceDelayRequests(bool delay_requests); | 445 void SetCorrectionServiceDelayRequests(bool delay_requests); |
446 void WaitForDelayedRequestDestruction(); | 446 void WaitForDelayedRequestDestruction(); |
447 void SetMockDnsClientRules(MockDnsClientRule::Result system_result, | 447 void SetMockDnsClientRules(MockDnsClientRule::Result system_result, |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 | 991 |
992 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE, | 992 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE, |
993 WaitForSentStatus()); | 993 WaitForSentStatus()); |
994 EXPECT_EQ(0, pending_status_count()); | 994 EXPECT_EQ(0, pending_status_count()); |
995 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED"); | 995 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED"); |
996 } | 996 } |
997 | 997 |
998 } // namespace | 998 } // namespace |
999 | 999 |
1000 } // namespace chrome_browser_net | 1000 } // namespace chrome_browser_net |
OLD | NEW |