| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 55 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 base::FilePath GetOnDiskPath(URLRequest* request) const { | 59 base::FilePath GetOnDiskPath(URLRequest* request) const { |
| 60 // Conceptually we just want to "return base_path_ + request->url().path()". | 60 // Conceptually we just want to "return base_path_ + request->url().path()". |
| 61 // But path in the request URL is in URL space (i.e. %-encoded spaces). | 61 // But path in the request URL is in URL space (i.e. %-encoded spaces). |
| 62 // So first we convert base FilePath to a URL, then append the URL | 62 // So first we convert base FilePath to a URL, then append the URL |
| 63 // path to that, and convert the final URL back to a FilePath. | 63 // path to that, and convert the final URL back to a FilePath. |
| 64 GURL file_url(FilePathToFileURL(base_path_)); | 64 GURL file_url(FilePathToFileURL(base_path_)); |
| 65 std::string url = file_url.spec() + request->url().path(); | 65 std::string url = file_url.spec() + request->url().path().as_string(); |
| 66 base::FilePath file_path; | 66 base::FilePath file_path; |
| 67 FileURLToFilePath(GURL(url), &file_path); | 67 FileURLToFilePath(GURL(url), &file_path); |
| 68 return file_path; | 68 return file_path; |
| 69 } | 69 } |
| 70 | 70 |
| 71 const base::FilePath base_path_; | 71 const base::FilePath base_path_; |
| 72 const bool map_all_requests_to_base_path_; | 72 const bool map_all_requests_to_base_path_; |
| 73 const scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 73 const scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(MockJobInterceptor); | 75 DISALLOW_COPY_AND_ASSIGN(MockJobInterceptor); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return URLRequestJob::GetResponseCode(); | 211 return URLRequestJob::GetResponseCode(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 214 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
| 215 HttpResponseInfo info; | 215 HttpResponseInfo info; |
| 216 GetResponseInfo(&info); | 216 GetResponseInfo(&info); |
| 217 return info.headers.get() && info.headers->GetCharset(charset); | 217 return info.headers.get() && info.headers->GetCharset(charset); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace net | 220 } // namespace net |
| OLD | NEW |