| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 TestURLFetcher(int id, | 82 TestURLFetcher(int id, |
| 83 const GURL& url, | 83 const GURL& url, |
| 84 URLFetcherDelegate* d); | 84 URLFetcherDelegate* d); |
| 85 virtual ~TestURLFetcher(); | 85 virtual ~TestURLFetcher(); |
| 86 | 86 |
| 87 // URLFetcher implementation | 87 // URLFetcher implementation |
| 88 virtual void SetUploadData(const std::string& upload_content_type, | 88 virtual void SetUploadData(const std::string& upload_content_type, |
| 89 const std::string& upload_content) OVERRIDE; | 89 const std::string& upload_content) OVERRIDE; |
| 90 virtual void SetUploadFilePath( |
| 91 const std::string& upload_content_type, |
| 92 const base::FilePath& file_path, |
| 93 scoped_refptr<base::TaskRunner> file_task_runner) OVERRIDE; |
| 90 virtual void SetChunkedUpload( | 94 virtual void SetChunkedUpload( |
| 91 const std::string& upload_content_type) OVERRIDE; | 95 const std::string& upload_content_type) OVERRIDE; |
| 92 // Overriden to cache the chunks uploaded. Caller can read back the uploaded | 96 // Overriden to cache the chunks uploaded. Caller can read back the uploaded |
| 93 // chunks with the upload_chunks() accessor. | 97 // chunks with the upload_chunks() accessor. |
| 94 virtual void AppendChunkToUpload(const std::string& data, | 98 virtual void AppendChunkToUpload(const std::string& data, |
| 95 bool is_last_chunk) OVERRIDE; | 99 bool is_last_chunk) OVERRIDE; |
| 96 virtual void SetLoadFlags(int load_flags) OVERRIDE; | 100 virtual void SetLoadFlags(int load_flags) OVERRIDE; |
| 97 virtual int GetLoadFlags() const OVERRIDE; | 101 virtual int GetLoadFlags() const OVERRIDE; |
| 98 virtual void SetReferrer(const std::string& referrer) OVERRIDE; | 102 virtual void SetReferrer(const std::string& referrer) OVERRIDE; |
| 99 virtual void SetExtraRequestHeaders( | 103 virtual void SetExtraRequestHeaders( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Sets owner of this class. Set it to a non-NULL value if you want | 148 // Sets owner of this class. Set it to a non-NULL value if you want |
| 145 // to automatically unregister this fetcher from the owning factory | 149 // to automatically unregister this fetcher from the owning factory |
| 146 // upon destruction. | 150 // upon destruction. |
| 147 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; } | 151 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; } |
| 148 | 152 |
| 149 // Unique ID in our factory. | 153 // Unique ID in our factory. |
| 150 int id() const { return id_; } | 154 int id() const { return id_; } |
| 151 | 155 |
| 152 // Returns the data uploaded on this URLFetcher. | 156 // Returns the data uploaded on this URLFetcher. |
| 153 const std::string& upload_data() const { return upload_data_; } | 157 const std::string& upload_data() const { return upload_data_; } |
| 158 const base::FilePath& upload_file_path() const { return upload_file_path_; } |
| 154 | 159 |
| 155 // Returns the chunks of data uploaded on this URLFetcher. | 160 // Returns the chunks of data uploaded on this URLFetcher. |
| 156 const std::list<std::string>& upload_chunks() const { return chunks_; } | 161 const std::list<std::string>& upload_chunks() const { return chunks_; } |
| 157 | 162 |
| 158 // Checks whether the last call to |AppendChunkToUpload(...)| was final. | 163 // Checks whether the last call to |AppendChunkToUpload(...)| was final. |
| 159 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } | 164 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } |
| 160 | 165 |
| 161 // Returns the delegate installed on the URLFetcher. | 166 // Returns the delegate installed on the URLFetcher. |
| 162 URLFetcherDelegate* delegate() const { return delegate_; } | 167 URLFetcherDelegate* delegate() const { return delegate_; } |
| 163 | 168 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 183 STRING, // Default: In a std::string | 188 STRING, // Default: In a std::string |
| 184 TEMP_FILE // Write to a temp file | 189 TEMP_FILE // Write to a temp file |
| 185 }; | 190 }; |
| 186 | 191 |
| 187 TestURLFetcherFactory* owner_; | 192 TestURLFetcherFactory* owner_; |
| 188 const int id_; | 193 const int id_; |
| 189 const GURL original_url_; | 194 const GURL original_url_; |
| 190 URLFetcherDelegate* delegate_; | 195 URLFetcherDelegate* delegate_; |
| 191 DelegateForTests* delegate_for_tests_; | 196 DelegateForTests* delegate_for_tests_; |
| 192 std::string upload_data_; | 197 std::string upload_data_; |
| 198 base::FilePath upload_file_path_; |
| 193 std::list<std::string> chunks_; | 199 std::list<std::string> chunks_; |
| 194 bool did_receive_last_chunk_; | 200 bool did_receive_last_chunk_; |
| 195 | 201 |
| 196 // User can use set_* methods to provide values returned by getters. | 202 // User can use set_* methods to provide values returned by getters. |
| 197 // Setting the real values is not possible, because the real class | 203 // Setting the real values is not possible, because the real class |
| 198 // has no setters. The data is a private member of a class defined | 204 // has no setters. The data is a private member of a class defined |
| 199 // in a .cc file, so we can't get at it with friendship. | 205 // in a .cc file, so we can't get at it with friendship. |
| 200 int fake_load_flags_; | 206 int fake_load_flags_; |
| 201 GURL fake_url_; | 207 GURL fake_url_; |
| 202 URLRequestStatus fake_status_; | 208 URLRequestStatus fake_status_; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 int id, | 411 int id, |
| 406 const GURL& url, | 412 const GURL& url, |
| 407 URLFetcher::RequestType request_type, | 413 URLFetcher::RequestType request_type, |
| 408 URLFetcherDelegate* d) OVERRIDE; | 414 URLFetcherDelegate* d) OVERRIDE; |
| 409 | 415 |
| 410 }; | 416 }; |
| 411 | 417 |
| 412 } // namespace net | 418 } // namespace net |
| 413 | 419 |
| 414 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 420 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |