OLD | NEW |
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 #include "net/test/url_request/url_request_mock_http_job.h" | 5 #include "net/test/url_request/url_request_mock_http_job.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 GURL URLRequestMockHTTPJob::GetMockUrl(const std::string& path) { | 113 GURL URLRequestMockHTTPJob::GetMockUrl(const std::string& path) { |
114 return GetMockUrlForScheme(path, "http"); | 114 return GetMockUrlForScheme(path, "http"); |
115 } | 115 } |
116 | 116 |
117 // static | 117 // static |
118 GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const std::string& path) { | 118 GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const std::string& path) { |
119 return GetMockUrlForScheme(path, "https"); | 119 return GetMockUrlForScheme(path, "https"); |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 GURL URLRequestMockHTTPJob::GetMockUrl(const base::FilePath& path) { | |
124 std::string path_str = path.MaybeAsASCII(); | |
125 DCHECK(!path_str.empty()); // We only expect ASCII paths in tests. | |
126 return GetMockUrlForScheme(path_str, "http"); | |
127 } | |
128 | |
129 // static | |
130 scoped_ptr<URLRequestInterceptor> URLRequestMockHTTPJob::CreateInterceptor( | 123 scoped_ptr<URLRequestInterceptor> URLRequestMockHTTPJob::CreateInterceptor( |
131 const base::FilePath& base_path, | 124 const base::FilePath& base_path, |
132 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) { | 125 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) { |
133 return scoped_ptr<URLRequestInterceptor>( | 126 return scoped_ptr<URLRequestInterceptor>( |
134 new MockJobInterceptor(base_path, false, worker_pool)); | 127 new MockJobInterceptor(base_path, false, worker_pool)); |
135 } | 128 } |
136 | 129 |
137 // static | 130 // static |
138 scoped_ptr<URLRequestInterceptor> | 131 scoped_ptr<URLRequestInterceptor> |
139 URLRequestMockHTTPJob::CreateInterceptorForSingleFile( | 132 URLRequestMockHTTPJob::CreateInterceptorForSingleFile( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return URLRequestJob::GetResponseCode(); | 202 return URLRequestJob::GetResponseCode(); |
210 } | 203 } |
211 | 204 |
212 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 205 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
213 HttpResponseInfo info; | 206 HttpResponseInfo info; |
214 GetResponseInfo(&info); | 207 GetResponseInfo(&info); |
215 return info.headers.get() && info.headers->GetCharset(charset); | 208 return info.headers.get() && info.headers->GetCharset(charset); |
216 } | 209 } |
217 | 210 |
218 } // namespace net | 211 } // namespace net |
OLD | NEW |