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

Unified Diff: content/test/net/url_request_prepackaged_interceptor.h

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years 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: content/test/net/url_request_prepackaged_interceptor.h
diff --git a/content/test/net/url_request_prepackaged_interceptor.h b/content/test/net/url_request_prepackaged_interceptor.h
new file mode 100644
index 0000000000000000000000000000000000000000..88b2291039bb913d54ca9accf57b1fd7dfb95f17
--- /dev/null
+++ b/content/test/net/url_request_prepackaged_interceptor.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_
+#define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_
+
+#include "base/basictypes.h"
+
+class FilePath;
+class GURL;
+
+namespace content {
+
+// Intercepts HTTP requests and gives pre-defined responses to specified URLs.
+// The pre-defined responses are loaded from files on disk. The interception
+// occurs while the URLRequestPrepackagedInterceptor is alive.
+class URLRequestPrepackagedInterceptor {
+ public:
+ URLRequestPrepackagedInterceptor();
+ virtual ~URLRequestPrepackagedInterceptor();
+
+ // When requests for |url| arrive, respond with the contents of |path|. The
+ // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme
+ // must be "http".
+ void SetResponse(const GURL& url, const FilePath& path);
+
+ // Identical to SetResponse except that query parameters are ignored on
+ // incoming URLs when comparing against |url|.
+ void SetResponseIgnoreQuery(const GURL& url, const FilePath& path);
+
+ // Returns how many requests have been issued that have a stored reply.
+ int GetHitCount();
+
+ private:
+ class Delegate;
+
+ // After creation, |delegate_| lives on the IO thread, and a task to delete
+ // it is posted from ~URLRequestPrepackagedInterceptor().
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedInterceptor);
+};
+
+} // namespace content
+
+#endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_
« no previous file with comments | « content/test/net/url_request_abort_on_end_job.cc ('k') | content/test/net/url_request_prepackaged_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698