Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: net/url_request/test_url_fetcher_factory.h

Issue 23625015: Consolidate TestURLFetcherFactory::SetFakeResponse (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Otherwise, it will return a URLFetcher object which will respond with the 370 // Otherwise, it will return a URLFetcher object which will respond with the
371 // pre-baked response that the client has set by calling SetFakeResponse(). 371 // pre-baked response that the client has set by calling SetFakeResponse().
372 virtual URLFetcher* CreateURLFetcher( 372 virtual URLFetcher* CreateURLFetcher(
373 int id, 373 int id,
374 const GURL& url, 374 const GURL& url,
375 URLFetcher::RequestType request_type, 375 URLFetcher::RequestType request_type,
376 URLFetcherDelegate* d) OVERRIDE; 376 URLFetcherDelegate* d) OVERRIDE;
377 377
378 // Sets the fake response for a given URL. If success is true we will serve 378 // Sets the fake response for a given URL. If success is true we will serve
379 // an HTTP/200 and an HTTP/500 otherwise. The |response_data| may be empty. 379 // an HTTP/200 and an HTTP/500 otherwise. The |response_data| may be empty.
380 void SetFakeResponseForURL(const GURL& url, 380 void SetFakeResponse(const GURL& url,
381 const std::string& response_data,
382 bool success);
383
384 // Convenience helper that calls SetFakeResponseForURL with GURL(url).
385 // TODO(mnissler): Convert callers to SetFakeResponseForURL.
386 void SetFakeResponse(const std::string& url,
387 const std::string& response_data, 381 const std::string& response_data,
388 bool success); 382 bool success);
389 383
390 // Clear all the fake responses that were previously set via 384 // Clear all the fake responses that were previously set via
391 // SetFakeResponse(). 385 // SetFakeResponse().
392 void ClearFakeResponses(); 386 void ClearFakeResponses();
393 387
394 private: 388 private:
395 const FakeURLFetcherCreator creator_; 389 const FakeURLFetcherCreator creator_;
396 typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap; 390 typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap;
(...skipping 22 matching lines...) Expand all
419 int id, 413 int id,
420 const GURL& url, 414 const GURL& url,
421 URLFetcher::RequestType request_type, 415 URLFetcher::RequestType request_type,
422 URLFetcherDelegate* d) OVERRIDE; 416 URLFetcherDelegate* d) OVERRIDE;
423 417
424 }; 418 };
425 419
426 } // namespace net 420 } // namespace net
427 421
428 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 422 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/printer_job_handler_unittest.cc ('k') | net/url_request/test_url_fetcher_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698