| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "net/base/load_timing_info.h" | 11 #include "net/base/load_timing_info.h" |
| 12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 13 #include "net/url_request/url_request_job.h" | 13 #include "net/url_request/url_request_job.h" |
| 14 #include "net/url_request/url_request_job_factory.h" | |
| 15 | 14 |
| 16 namespace net { | 15 namespace net { |
| 17 | 16 |
| 18 // This job type is designed to help with simple unit tests. To use, you | 17 // This job type is designed to help with simple unit tests. To use, you |
| 19 // probably want to inherit from it to set up the state you want. Then install | 18 // probably want to inherit from it to set up the state you want. Then install |
| 20 // it as the protocol handler for the "test" scheme. | 19 // it as the protocol handler for the "test" scheme. |
| 21 // | 20 // |
| 22 // It will respond to several URLs, which you can retrieve using the test_url* | 21 // It will respond to several URLs, which you can retrieve using the test_url* |
| 23 // getters, which will in turn respond with the corresponding responses returned | 22 // getters, which will in turn respond with the corresponding responses returned |
| 24 // by test_data*. Any other URLs that begin with "test:" will return an error, | 23 // by test_data*. Any other URLs that begin with "test:" will return an error, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Should not be altered after the job has started. | 96 // Should not be altered after the job has started. |
| 98 bool auto_advance() { return auto_advance_; } | 97 bool auto_advance() { return auto_advance_; } |
| 99 void set_auto_advance(bool auto_advance) { auto_advance_ = auto_advance; } | 98 void set_auto_advance(bool auto_advance) { auto_advance_ = auto_advance; } |
| 100 | 99 |
| 101 void set_load_timing_info(const LoadTimingInfo& load_timing_info) { | 100 void set_load_timing_info(const LoadTimingInfo& load_timing_info) { |
| 102 load_timing_info_ = load_timing_info; | 101 load_timing_info_ = load_timing_info; |
| 103 } | 102 } |
| 104 | 103 |
| 105 RequestPriority priority() const { return priority_; } | 104 RequestPriority priority() const { return priority_; } |
| 106 | 105 |
| 107 // Create a protocol handler for callers that don't subclass. | 106 // Factory method for protocol factory registration if callers don't subclass |
| 108 static URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler(); | 107 static URLRequest::ProtocolFactory Factory; |
| 109 | 108 |
| 110 // Job functions | 109 // Job functions |
| 111 virtual void SetPriority(RequestPriority priority) OVERRIDE; | 110 virtual void SetPriority(RequestPriority priority) OVERRIDE; |
| 112 virtual void Start() OVERRIDE; | 111 virtual void Start() OVERRIDE; |
| 113 virtual bool ReadRawData(IOBuffer* buf, | 112 virtual bool ReadRawData(IOBuffer* buf, |
| 114 int buf_size, | 113 int buf_size, |
| 115 int *bytes_read) OVERRIDE; | 114 int *bytes_read) OVERRIDE; |
| 116 virtual void Kill() OVERRIDE; | 115 virtual void Kill() OVERRIDE; |
| 117 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 116 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 118 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; | 117 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 int async_buf_size_; | 166 int async_buf_size_; |
| 168 | 167 |
| 169 LoadTimingInfo load_timing_info_; | 168 LoadTimingInfo load_timing_info_; |
| 170 | 169 |
| 171 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; | 170 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; |
| 172 }; | 171 }; |
| 173 | 172 |
| 174 } // namespace net | 173 } // namespace net |
| 175 | 174 |
| 176 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 175 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| OLD | NEW |