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

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

Issue 845973005: [New Tab Page] Change the mechanism to intercept online NTP errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove file Created 5 years, 11 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.cc
diff --git a/net/test/url_request/url_request_mock_http_job.cc b/net/test/url_request/url_request_mock_http_job.cc
index ede87cfeabdb86a0fb1fb849699f339cc3fc4e65..d8dd8c8809291f3da201348e133a46270aa940ba 100644
--- a/net/test/url_request/url_request_mock_http_job.cc
+++ b/net/test/url_request/url_request_mock_http_job.cc
@@ -99,13 +99,15 @@ std::string DoFileIO(const base::FilePath& file_path) {
} // namespace
// static
-void URLRequestMockHTTPJob::AddUrlHandler(
+void URLRequestMockHTTPJob::AddUrlHandlers(
const base::FilePath& base_path,
const scoped_refptr<base::SequencedWorkerPool>& worker_pool) {
- // Add kMockHostname to net::URLRequestFilter.
+ // Add kMockHostname to net::URLRequestFilter, for both HTTP and HTTPS.
net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance();
filter->AddHostnameInterceptor(
"http", kMockHostname, CreateInterceptor(base_path, worker_pool));
+ filter->AddHostnameInterceptor("https", kMockHostname,
+ CreateInterceptor(base_path, worker_pool));
}
// static
@@ -120,13 +122,12 @@ void URLRequestMockHTTPJob::AddHostnameToFileHandler(
// static
GURL URLRequestMockHTTPJob::GetMockUrl(const base::FilePath& path) {
- std::string url = "http://";
- url.append(kMockHostname);
- url.append("/");
- std::string path_str = path.MaybeAsASCII();
- DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
- url.append(path_str);
- return GURL(url);
+ return GetMockUrlForScheme(path, "http");
+}
+
+// static
+GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const base::FilePath& path) {
+ return GetMockUrlForScheme(path, "https");
}
// static
@@ -175,6 +176,18 @@ URLRequestMockHTTPJob::URLRequestMockHTTPJob(
URLRequestMockHTTPJob::~URLRequestMockHTTPJob() {
}
+// static
+GURL URLRequestMockHTTPJob::GetMockUrlForScheme(const base::FilePath& path,
mmenke 2015/01/15 22:35:30 nit: Instead of making this a static member of UR
Mathieu 2015/01/22 19:21:59 Done.
+ const std::string& scheme) {
+ std::string url = scheme + "://";
+ url.append(kMockHostname);
+ url.append("/");
+ std::string path_str = path.MaybeAsASCII();
+ DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
+ url.append(path_str);
+ return GURL(url);
+}
+
// Public virtual version.
void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) {
// Forward to private const version.

Powered by Google App Engine
This is Rietveld 408576698