| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 int64_t GetTotalReceivedBytes() const override; | 142 int64_t GetTotalReceivedBytes() const override; |
| 143 void Start() override; | 143 void Start() override; |
| 144 | 144 |
| 145 // URL we were created with. Because of how we're using URLFetcher GetURL() | 145 // URL we were created with. Because of how we're using URLFetcher GetURL() |
| 146 // always returns an empty URL. Chances are you'll want to use | 146 // always returns an empty URL. Chances are you'll want to use |
| 147 // GetOriginalURL() in your tests. | 147 // GetOriginalURL() in your tests. |
| 148 const GURL& GetOriginalURL() const override; | 148 const GURL& GetOriginalURL() const override; |
| 149 const GURL& GetURL() const override; | 149 const GURL& GetURL() const override; |
| 150 const URLRequestStatus& GetStatus() const override; | 150 const URLRequestStatus& GetStatus() const override; |
| 151 int GetResponseCode() const override; | 151 int GetResponseCode() const override; |
| 152 const ResponseCookies& GetCookies() const override; | |
| 153 void ReceivedContentWasMalformed() override; | 152 void ReceivedContentWasMalformed() override; |
| 154 // Override response access functions to return fake data. | 153 // Override response access functions to return fake data. |
| 155 bool GetResponseAsString(std::string* out_response_string) const override; | 154 bool GetResponseAsString(std::string* out_response_string) const override; |
| 156 bool GetResponseAsFilePath(bool take_ownership, | 155 bool GetResponseAsFilePath(bool take_ownership, |
| 157 base::FilePath* out_response_path) const override; | 156 base::FilePath* out_response_path) const override; |
| 158 | 157 |
| 159 void GetExtraRequestHeaders(HttpRequestHeaders* headers) const; | 158 void GetExtraRequestHeaders(HttpRequestHeaders* headers) const; |
| 160 | 159 |
| 161 // Sets owner of this class. Set it to a non-NULL value if you want | 160 // Sets owner of this class. Set it to a non-NULL value if you want |
| 162 // to automatically unregister this fetcher from the owning factory | 161 // to automatically unregister this fetcher from the owning factory |
| (...skipping 17 matching lines...) Expand all Loading... |
| 180 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } | 179 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } |
| 181 | 180 |
| 182 // Returns the delegate installed on the URLFetcher. | 181 // Returns the delegate installed on the URLFetcher. |
| 183 URLFetcherDelegate* delegate() const { return delegate_; } | 182 URLFetcherDelegate* delegate() const { return delegate_; } |
| 184 | 183 |
| 185 void set_url(const GURL& url) { fake_url_ = url; } | 184 void set_url(const GURL& url) { fake_url_ = url; } |
| 186 void set_status(const URLRequestStatus& status); | 185 void set_status(const URLRequestStatus& status); |
| 187 void set_response_code(int response_code) { | 186 void set_response_code(int response_code) { |
| 188 fake_response_code_ = response_code; | 187 fake_response_code_ = response_code; |
| 189 } | 188 } |
| 190 void set_cookies(const ResponseCookies& c) { fake_cookies_ = c; } | |
| 191 void set_was_fetched_via_proxy(bool flag); | 189 void set_was_fetched_via_proxy(bool flag); |
| 192 void set_was_cached(bool flag); | 190 void set_was_cached(bool flag); |
| 193 void set_response_headers(scoped_refptr<HttpResponseHeaders> headers); | 191 void set_response_headers(scoped_refptr<HttpResponseHeaders> headers); |
| 194 void set_backoff_delay(base::TimeDelta backoff_delay); | 192 void set_backoff_delay(base::TimeDelta backoff_delay); |
| 195 void SetDelegateForTests(DelegateForTests* delegate_for_tests); | 193 void SetDelegateForTests(DelegateForTests* delegate_for_tests); |
| 196 | 194 |
| 197 // Set string data. | 195 // Set string data. |
| 198 void SetResponseString(const std::string& response); | 196 void SetResponseString(const std::string& response); |
| 199 | 197 |
| 200 // Set File data. | 198 // Set File data. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 218 bool did_receive_last_chunk_; | 216 bool did_receive_last_chunk_; |
| 219 | 217 |
| 220 // User can use set_* methods to provide values returned by getters. | 218 // User can use set_* methods to provide values returned by getters. |
| 221 // Setting the real values is not possible, because the real class | 219 // Setting the real values is not possible, because the real class |
| 222 // has no setters. The data is a private member of a class defined | 220 // has no setters. The data is a private member of a class defined |
| 223 // in a .cc file, so we can't get at it with friendship. | 221 // in a .cc file, so we can't get at it with friendship. |
| 224 int fake_load_flags_; | 222 int fake_load_flags_; |
| 225 GURL fake_url_; | 223 GURL fake_url_; |
| 226 URLRequestStatus fake_status_; | 224 URLRequestStatus fake_status_; |
| 227 int fake_response_code_; | 225 int fake_response_code_; |
| 228 ResponseCookies fake_cookies_; | |
| 229 ResponseDestinationType fake_response_destination_; | 226 ResponseDestinationType fake_response_destination_; |
| 230 std::string fake_response_string_; | 227 std::string fake_response_string_; |
| 231 base::FilePath fake_response_file_path_; | 228 base::FilePath fake_response_file_path_; |
| 232 bool write_response_file_; | 229 bool write_response_file_; |
| 233 bool fake_was_fetched_via_proxy_; | 230 bool fake_was_fetched_via_proxy_; |
| 234 bool fake_was_cached_; | 231 bool fake_was_cached_; |
| 235 int64_t fake_response_bytes_; | 232 int64_t fake_response_bytes_; |
| 236 scoped_refptr<HttpResponseHeaders> fake_response_headers_; | 233 scoped_refptr<HttpResponseHeaders> fake_response_headers_; |
| 237 HttpRequestHeaders fake_extra_request_headers_; | 234 HttpRequestHeaders fake_extra_request_headers_; |
| 238 int fake_max_retries_; | 235 int fake_max_retries_; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 std::unique_ptr<URLFetcher> CreateURLFetcher( | 469 std::unique_ptr<URLFetcher> CreateURLFetcher( |
| 473 int id, | 470 int id, |
| 474 const GURL& url, | 471 const GURL& url, |
| 475 URLFetcher::RequestType request_type, | 472 URLFetcher::RequestType request_type, |
| 476 URLFetcherDelegate* d) override; | 473 URLFetcherDelegate* d) override; |
| 477 }; | 474 }; |
| 478 | 475 |
| 479 } // namespace net | 476 } // namespace net |
| 480 | 477 |
| 481 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 478 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |