Chromium Code Reviews| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 // Sets the fake response for a given URL. If success is true we will serve | 310 // Sets the fake response for a given URL. If success is true we will serve |
| 311 // an HTTP/200 and an HTTP/500 otherwise. The |response_data| may be empty. | 311 // an HTTP/200 and an HTTP/500 otherwise. The |response_data| may be empty. |
| 312 void SetFakeResponse(const std::string& url, | 312 void SetFakeResponse(const std::string& url, |
| 313 const std::string& response_data, | 313 const std::string& response_data, |
| 314 bool success); | 314 bool success); |
| 315 | 315 |
| 316 // Clear all the fake responses that were previously set via | 316 // Clear all the fake responses that were previously set via |
| 317 // SetFakeResponse(). | 317 // SetFakeResponse(). |
| 318 void ClearFakeResponses(); | 318 void ClearFakeResponses(); |
| 319 | 319 |
| 320 protected: | |
| 321 // For use when subclassing FakeURLFetcherFactory. | |
| 322 // If no fake response is set, return NULL. | |
| 323 virtual TestURLFetcher* CreateFakeURLFetcher(const GURL& URL, | |
|
akalin
2013/02/08 07:47:35
I'm confused by the need for this. FakeURLFetcher
Noam Samuel (WRONG ACCOUNT)
2013/02/08 16:27:10
The main scenario I'm trying to support is the abi
noelutz
2013/02/08 18:21:40
I don't have a strong opinion here but I would als
Noam Samuel (WRONG ACCOUNT)
2013/02/08 18:58:44
Not sure how that would work. The FakeURLFetcherFa
| |
| 324 URLFetcher::RequestType request_type, | |
| 325 URLFetcherDelegate* d); | |
| 326 | |
| 320 private: | 327 private: |
| 321 typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap; | 328 typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap; |
| 322 FakeResponseMap fake_responses_; | 329 FakeResponseMap fake_responses_; |
| 323 URLFetcherFactory* default_factory_; | 330 URLFetcherFactory* default_factory_; |
| 324 | 331 |
| 325 DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory); | 332 DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory); |
| 326 }; | 333 }; |
| 327 | 334 |
| 328 // This is an implementation of URLFetcherFactory that will create a | 335 // This is an implementation of URLFetcherFactory that will create a |
| 329 // URLFetcherImpl. It can be use in conjunction with a FakeURLFetcherFactory in | 336 // URLFetcherImpl. It can be use in conjunction with a FakeURLFetcherFactory in |
| 330 // integration tests to control the behavior of some requests but execute | 337 // integration tests to control the behavior of some requests but execute |
| 331 // all the other ones. | 338 // all the other ones. |
| 332 class URLFetcherImplFactory : public URLFetcherFactory { | 339 class URLFetcherImplFactory : public URLFetcherFactory { |
| 333 public: | 340 public: |
| 334 URLFetcherImplFactory(); | 341 URLFetcherImplFactory(); |
| 335 virtual ~URLFetcherImplFactory(); | 342 virtual ~URLFetcherImplFactory(); |
| 336 | 343 |
| 337 // This method will create a real URLFetcher. | 344 // This method will create a real URLFetcher. |
| 338 virtual URLFetcher* CreateURLFetcher( | 345 virtual URLFetcher* CreateURLFetcher( |
| 339 int id, | 346 int id, |
| 340 const GURL& url, | 347 const GURL& url, |
| 341 URLFetcher::RequestType request_type, | 348 URLFetcher::RequestType request_type, |
| 342 URLFetcherDelegate* d) OVERRIDE; | 349 URLFetcherDelegate* d) OVERRIDE; |
| 343 | 350 |
| 344 }; | 351 }; |
| 345 | 352 |
| 346 } // namespace net | 353 } // namespace net |
| 347 | 354 |
| 348 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 355 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |