| 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 scoped_ptr<URLRequestInterceptor> URLRequestMockHTTPJob::CreateInterceptor( | 123 std::unique_ptr<URLRequestInterceptor> URLRequestMockHTTPJob::CreateInterceptor( |
| 124 const base::FilePath& base_path, | 124 const base::FilePath& base_path, |
| 125 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) { | 125 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) { |
| 126 return scoped_ptr<URLRequestInterceptor>( | 126 return std::unique_ptr<URLRequestInterceptor>( |
| 127 new MockJobInterceptor(base_path, false, worker_pool)); | 127 new MockJobInterceptor(base_path, false, worker_pool)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // static | 130 // static |
| 131 scoped_ptr<URLRequestInterceptor> | 131 std::unique_ptr<URLRequestInterceptor> |
| 132 URLRequestMockHTTPJob::CreateInterceptorForSingleFile( | 132 URLRequestMockHTTPJob::CreateInterceptorForSingleFile( |
| 133 const base::FilePath& file, | 133 const base::FilePath& file, |
| 134 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) { | 134 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) { |
| 135 return scoped_ptr<URLRequestInterceptor>( | 135 return std::unique_ptr<URLRequestInterceptor>( |
| 136 new MockJobInterceptor(file, true, worker_pool)); | 136 new MockJobInterceptor(file, true, worker_pool)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 URLRequestMockHTTPJob::URLRequestMockHTTPJob( | 139 URLRequestMockHTTPJob::URLRequestMockHTTPJob( |
| 140 URLRequest* request, | 140 URLRequest* request, |
| 141 NetworkDelegate* network_delegate, | 141 NetworkDelegate* network_delegate, |
| 142 const base::FilePath& file_path, | 142 const base::FilePath& file_path, |
| 143 const scoped_refptr<base::TaskRunner>& task_runner) | 143 const scoped_refptr<base::TaskRunner>& task_runner) |
| 144 : URLRequestFileJob(request, network_delegate, file_path, task_runner), | 144 : URLRequestFileJob(request, network_delegate, file_path, task_runner), |
| 145 task_runner_(task_runner), | 145 task_runner_(task_runner), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return URLRequestJob::GetResponseCode(); | 202 return URLRequestJob::GetResponseCode(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 205 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
| 206 HttpResponseInfo info; | 206 HttpResponseInfo info; |
| 207 GetResponseInfo(&info); | 207 GetResponseInfo(&info); |
| 208 return info.headers.get() && info.headers->GetCharset(charset); | 208 return info.headers.get() && info.headers->GetCharset(charset); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace net | 211 } // namespace net |
| OLD | NEW |