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

Unified Diff: net/test/url_request/url_request_mock_http_job.h

Issue 541743002: Move url_request_mock_http_job to net/test/url_request/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed one unmatched brace 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: net/test/url_request/url_request_mock_http_job.h
diff --git a/net/test/url_request/url_request_mock_http_job.h b/net/test/url_request/url_request_mock_http_job.h
new file mode 100644
index 0000000000000000000000000000000000000000..9433cc42d0b3dc50ba85357fe1d770375083e228
--- /dev/null
+++ b/net/test/url_request/url_request_mock_http_job.h
@@ -0,0 +1,85 @@
+// 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.
+//
+// A URLRequestJob class that pulls the net and http headers from disk.
+
+#ifndef NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_
+#define NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_
+
+#include <string>
+
+#include "net/url_request/url_request_file_job.h"
+
+namespace base {
+class FilePath;
mmenke 2014/09/04 19:02:38 Think you missed some of my comment in this file (
xunjieli 2014/09/04 19:24:16 Acknowledged.
+}
+
+namespace net {
+class URLRequestInterceptor;
+}
+
+namespace net {
+
+class URLRequestMockHTTPJob : public URLRequestFileJob {
+ public:
+ URLRequestMockHTTPJob(
+ URLRequest* request,
+ NetworkDelegate* network_delegate,
+ const base::FilePath& file_path,
+ const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
+
+ virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
+ virtual int GetResponseCode() const OVERRIDE;
+ virtual bool GetCharset(std::string* charset) OVERRIDE;
+ virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE;
+ virtual bool IsRedirectResponse(GURL* location,
+ int* http_status_code) OVERRIDE;
+
+ // Adds the testing URLs to the URLRequestFilter.
+ static void AddUrlHandler(
+ const base::FilePath& base_path,
+ const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
mmenke 2014/09/04 19:02:38 Should include base/memory/ref_counted.h here (And
xunjieli 2014/09/04 19:24:16 Done.
+
+ // Respond to all HTTP requests of |hostname| with contents of the file
+ // located at |file_path|.
+ static void AddHostnameToFileHandler(
+ const std::string& hostname,
+ const base::FilePath& file,
+ const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
+
+ // Given the path to a file relative to the path passed to AddUrlHandler(),
+ // construct a mock URL.
+ static GURL GetMockUrl(const base::FilePath& path);
+
+ // Given the path to a file relative to the path passed to AddUrlHandler(),
+ // construct a mock URL for view source.
+ static GURL GetMockViewSourceUrl(const base::FilePath& path);
+
+ // Returns a URLRequestJobFactory::ProtocolHandler that serves
+ // URLRequestMockHTTPJob's responding like an HTTP server. |base_path| is the
+ // file path leading to the root of the directory to use as the root of the
+ // HTTP server.
+ static scoped_ptr<URLRequestInterceptor>
+ CreateInterceptor(
+ const base::FilePath& base_path,
+ const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
+
+ // Returns a URLRequestJobFactory::ProtocolHandler that serves
+ // URLRequestMockHTTPJob's responding like an HTTP server. It responds to all
+ // requests with the contents of |file|.
+ static scoped_ptr<URLRequestInterceptor>
+ CreateInterceptorForSingleFile(
+ const base::FilePath& file,
+ const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
+
+ protected:
+ virtual ~URLRequestMockHTTPJob();
+
+ private:
+ void GetResponseInfoConst(HttpResponseInfo* info) const;
+};
+
+} // namespace net
+
+#endif // NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_

Powered by Google App Engine
This is Rietveld 408576698