| 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_TEST_URL_FETCHER_FACTORY_H_ | 5 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| 6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Callback issued correspondingly to the destructor. | 74 // Callback issued correspondingly to the destructor. |
| 75 virtual void OnRequestEnd(int fetcher_id) = 0; | 75 virtual void OnRequestEnd(int fetcher_id) = 0; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 TestURLFetcher(int id, | 78 TestURLFetcher(int id, |
| 79 const GURL& url, | 79 const GURL& url, |
| 80 URLFetcherDelegate* d); | 80 URLFetcherDelegate* d); |
| 81 virtual ~TestURLFetcher(); | 81 virtual ~TestURLFetcher(); |
| 82 | 82 |
| 83 // URLFetcher implementation | 83 // URLFetcher implementation |
| 84 virtual void SetUploadDataStream( | |
| 85 const std::string& upload_content_type, | |
| 86 scoped_ptr<UploadDataStream> upload_content) OVERRIDE; | |
| 87 virtual void SetUploadData(const std::string& upload_content_type, | 84 virtual void SetUploadData(const std::string& upload_content_type, |
| 88 const std::string& upload_content) OVERRIDE; | 85 const std::string& upload_content) OVERRIDE; |
| 89 virtual void SetChunkedUpload( | 86 virtual void SetChunkedUpload( |
| 90 const std::string& upload_content_type) OVERRIDE; | 87 const std::string& upload_content_type) OVERRIDE; |
| 91 // Overriden to cache the chunks uploaded. Caller can read back the uploaded | 88 // Overriden to cache the chunks uploaded. Caller can read back the uploaded |
| 92 // chunks with the upload_chunks() accessor. | 89 // chunks with the upload_chunks() accessor. |
| 93 virtual void AppendChunkToUpload(const std::string& data, | 90 virtual void AppendChunkToUpload(const std::string& data, |
| 94 bool is_last_chunk) OVERRIDE; | 91 bool is_last_chunk) OVERRIDE; |
| 95 virtual void SetLoadFlags(int load_flags) OVERRIDE; | 92 virtual void SetLoadFlags(int load_flags) OVERRIDE; |
| 96 virtual int GetLoadFlags() const OVERRIDE; | 93 virtual int GetLoadFlags() const OVERRIDE; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool take_ownership, base::FilePath* out_response_path) const OVERRIDE; | 138 bool take_ownership, base::FilePath* out_response_path) const OVERRIDE; |
| 142 | 139 |
| 143 // Sets owner of this class. Set it to a non-NULL value if you want | 140 // Sets owner of this class. Set it to a non-NULL value if you want |
| 144 // to automatically unregister this fetcher from the owning factory | 141 // to automatically unregister this fetcher from the owning factory |
| 145 // upon destruction. | 142 // upon destruction. |
| 146 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; } | 143 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; } |
| 147 | 144 |
| 148 // Unique ID in our factory. | 145 // Unique ID in our factory. |
| 149 int id() const { return id_; } | 146 int id() const { return id_; } |
| 150 | 147 |
| 151 // Returns the data stream uploaded on this URLFetcher. | |
| 152 const UploadDataStream* upload_data_stream() const { | |
| 153 return upload_data_stream_.get(); | |
| 154 } | |
| 155 | |
| 156 // Returns the data uploaded on this URLFetcher. | 148 // Returns the data uploaded on this URLFetcher. |
| 157 const std::string& upload_data() const { return upload_data_; } | 149 const std::string& upload_data() const { return upload_data_; } |
| 158 | 150 |
| 159 // Returns the chunks of data uploaded on this URLFetcher. | 151 // Returns the chunks of data uploaded on this URLFetcher. |
| 160 const std::list<std::string>& upload_chunks() const { return chunks_; } | 152 const std::list<std::string>& upload_chunks() const { return chunks_; } |
| 161 | 153 |
| 162 // Checks whether the last call to |AppendChunkToUpload(...)| was final. | 154 // Checks whether the last call to |AppendChunkToUpload(...)| was final. |
| 163 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } | 155 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } |
| 164 | 156 |
| 165 // Returns the delegate installed on the URLFetcher. | 157 // Returns the delegate installed on the URLFetcher. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 187 STRING, // Default: In a std::string | 179 STRING, // Default: In a std::string |
| 188 TEMP_FILE // Write to a temp file | 180 TEMP_FILE // Write to a temp file |
| 189 }; | 181 }; |
| 190 | 182 |
| 191 TestURLFetcherFactory* owner_; | 183 TestURLFetcherFactory* owner_; |
| 192 const int id_; | 184 const int id_; |
| 193 const GURL original_url_; | 185 const GURL original_url_; |
| 194 URLFetcherDelegate* delegate_; | 186 URLFetcherDelegate* delegate_; |
| 195 DelegateForTests* delegate_for_tests_; | 187 DelegateForTests* delegate_for_tests_; |
| 196 std::string upload_data_; | 188 std::string upload_data_; |
| 197 scoped_ptr<UploadDataStream> upload_data_stream_; | |
| 198 std::list<std::string> chunks_; | 189 std::list<std::string> chunks_; |
| 199 bool did_receive_last_chunk_; | 190 bool did_receive_last_chunk_; |
| 200 | 191 |
| 201 // User can use set_* methods to provide values returned by getters. | 192 // User can use set_* methods to provide values returned by getters. |
| 202 // Setting the real values is not possible, because the real class | 193 // Setting the real values is not possible, because the real class |
| 203 // has no setters. The data is a private member of a class defined | 194 // has no setters. The data is a private member of a class defined |
| 204 // in a .cc file, so we can't get at it with friendship. | 195 // in a .cc file, so we can't get at it with friendship. |
| 205 int fake_load_flags_; | 196 int fake_load_flags_; |
| 206 GURL fake_url_; | 197 GURL fake_url_; |
| 207 URLRequestStatus fake_status_; | 198 URLRequestStatus fake_status_; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 int id, | 330 int id, |
| 340 const GURL& url, | 331 const GURL& url, |
| 341 URLFetcher::RequestType request_type, | 332 URLFetcher::RequestType request_type, |
| 342 URLFetcherDelegate* d) OVERRIDE; | 333 URLFetcherDelegate* d) OVERRIDE; |
| 343 | 334 |
| 344 }; | 335 }; |
| 345 | 336 |
| 346 } // namespace net | 337 } // namespace net |
| 347 | 338 |
| 348 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 339 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |