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

Unified Diff: components/component_updater/test/url_request_post_interceptor.h

Issue 565363002: Implement support for fallback update check urls in the component updater (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/component_updater/test/url_request_post_interceptor.h
diff --git a/components/component_updater/test/url_request_post_interceptor.h b/components/component_updater/test/url_request_post_interceptor.h
index afe6a2e8f283674553d92a8a6666dff7c80b5ae1..9c60c610445cae81965484c78507ddc46ddf60c6 100644
--- a/components/component_updater/test/url_request_post_interceptor.h
+++ b/components/component_updater/test/url_request_post_interceptor.h
@@ -66,9 +66,12 @@ class URLRequestPostInterceptor {
// Sets an expection for the body of the POST request and optionally,
// provides a canned response identified by a |file_path| to be returned when
// the expectation is met. If no |file_path| is provided, then an empty
- // response body is served. This class takes ownership of the
- // |request_matcher| object. Returns |true| if the expectation was set.
+ // response body is served. If |response_code| is provided, then an empty
+ // response body with that response code is returned.
+ // Returns |true| if the expectation was set. This class takes ownership of
+ // the |request_matcher| object.
bool ExpectRequest(class RequestMatcher* request_matcher);
+ bool ExpectRequest(class RequestMatcher* request_matcher, int response_code);
bool ExpectRequest(class RequestMatcher* request_matcher,
const base::FilePath& filepath);
@@ -92,7 +95,16 @@ class URLRequestPostInterceptor {
private:
friend class URLRequestPostInterceptorFactory;
- typedef std::pair<const RequestMatcher*, std::string> Expectation;
+
+ static const int kResponseCode200 = 200;
+
+ struct ExpectationResponse {
+ ExpectationResponse(int code, const std::string& body)
+ : response_code(code), response_body(body) {}
+ const int response_code;
+ const std::string response_body;
+ };
+ typedef std::pair<const RequestMatcher*, ExpectationResponse> Expectation;
URLRequestPostInterceptor(
const GURL& url,
@@ -100,6 +112,7 @@ class URLRequestPostInterceptor {
~URLRequestPostInterceptor();
void ClearExpectations();
+
const GURL url_;
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
@@ -144,8 +157,12 @@ class InterceptorFactory : public URLRequestPostInterceptorFactory {
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
~InterceptorFactory();
+ // Creates an interceptor for the url path defined by POST_INTERCEPT_PATH.
URLRequestPostInterceptor* CreateInterceptor();
+ // Creates an interceptor for the given url path.
+ URLRequestPostInterceptor* CreateInterceptorForPath(const char* url_path);
+
private:
DISALLOW_COPY_AND_ASSIGN(InterceptorFactory);
};

Powered by Google App Engine
This is Rietveld 408576698