OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/url_request/url_request_job_factory.h" | 5 #include "net/url_request/url_request_job_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "net/url_request/url_request_job.h" | 9 #include "net/url_request/url_request_job.h" |
10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 virtual void Start() { | 24 virtual void Start() { |
25 // Start reading asynchronously so that all error reporting and data | 25 // Start reading asynchronously so that all error reporting and data |
26 // callbacks happen as they would for network requests. | 26 // callbacks happen as they would for network requests. |
27 MessageLoop::current()->PostTask( | 27 MessageLoop::current()->PostTask( |
28 FROM_HERE, | 28 FROM_HERE, |
29 base::Bind(&MockURLRequestJob::StartAsync, | 29 base::Bind(&MockURLRequestJob::StartAsync, |
30 weak_factory_.GetWeakPtr())); | 30 weak_factory_.GetWeakPtr())); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
| 34 virtual ~MockURLRequestJob() {} |
| 35 |
34 void StartAsync() { | 36 void StartAsync() { |
35 SetStatus(status_); | 37 SetStatus(status_); |
36 NotifyHeadersComplete(); | 38 NotifyHeadersComplete(); |
37 } | 39 } |
38 | 40 |
39 URLRequestStatus status_; | 41 URLRequestStatus status_; |
40 base::WeakPtrFactory<MockURLRequestJob> weak_factory_; | 42 base::WeakPtrFactory<MockURLRequestJob> weak_factory_; |
41 }; | 43 }; |
42 | 44 |
43 class DummyProtocolHandler : public URLRequestJobFactory::ProtocolHandler { | 45 class DummyProtocolHandler : public URLRequestJobFactory::ProtocolHandler { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 EXPECT_FALSE(interceptor->WillHandleProtocol("anything")); | 204 EXPECT_FALSE(interceptor->WillHandleProtocol("anything")); |
203 EXPECT_FALSE(job_factory.IsHandledProtocol("anything")); | 205 EXPECT_FALSE(job_factory.IsHandledProtocol("anything")); |
204 interceptor->handle_all_protocols_ = true; | 206 interceptor->handle_all_protocols_ = true; |
205 EXPECT_TRUE(interceptor->WillHandleProtocol("anything")); | 207 EXPECT_TRUE(interceptor->WillHandleProtocol("anything")); |
206 EXPECT_TRUE(job_factory.IsHandledProtocol("anything")); | 208 EXPECT_TRUE(job_factory.IsHandledProtocol("anything")); |
207 } | 209 } |
208 | 210 |
209 } // namespace | 211 } // namespace |
210 | 212 |
211 } // namespace net | 213 } // namespace net |
OLD | NEW |