| Index: chrome/browser/automation/url_request_mock_http_job.cc
|
| diff --git a/chrome/browser/automation/url_request_mock_http_job.cc b/chrome/browser/automation/url_request_mock_http_job.cc
|
| index 4bb191ac3eac5bb5bc503f162c91fc1d652a352a..4d212a530f946fccf1b55429dc5fa3e6d5a3fdb5 100644
|
| --- a/chrome/browser/automation/url_request_mock_http_job.cc
|
| +++ b/chrome/browser/automation/url_request_mock_http_job.cc
|
| @@ -19,22 +19,8 @@ std::wstring URLRequestMockHTTPJob::base_path_ = L"";
|
| /* static */
|
| URLRequestJob* URLRequestMockHTTPJob::Factory(URLRequest* request,
|
| const std::string& scheme) {
|
| - std::wstring file_url(L"file:///");
|
| - file_url += base_path_;
|
| - const std::string& url = request->url().spec();
|
| - // Fix up the url to be the file url we're loading from disk.
|
| - std::string host_prefix("http://");
|
| - host_prefix.append(kMockHostname);
|
| - size_t host_prefix_len = host_prefix.length();
|
| - if (url.compare(0, host_prefix_len, host_prefix.data(),
|
| - host_prefix_len) == 0) {
|
| - file_url += UTF8ToWide(url.substr(host_prefix_len));
|
| - }
|
| -
|
| - // Convert the file:/// URL to a path on disk.
|
| - FilePath file_path;
|
| - net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
|
| - return new URLRequestMockHTTPJob(request, file_path);
|
| + return new URLRequestMockHTTPJob(request,
|
| + GetOnDiskPath(base_path_, request, scheme));
|
| }
|
|
|
| /* static */
|
| @@ -56,6 +42,28 @@ GURL URLRequestMockHTTPJob::GetMockUrl(const std::wstring& path) {
|
| return GURL(url);
|
| }
|
|
|
| +/* static */
|
| +FilePath URLRequestMockHTTPJob::GetOnDiskPath(const std::wstring& base_path,
|
| + URLRequest* request,
|
| + const std::string& scheme) {
|
| + std::wstring file_url(L"file:///");
|
| + file_url += base_path;
|
| + const std::string& url = request->url().spec();
|
| + // Fix up the url to be the file url we're loading from disk.
|
| + std::string host_prefix("http://");
|
| + host_prefix.append(kMockHostname);
|
| + size_t host_prefix_len = host_prefix.length();
|
| + if (url.compare(0, host_prefix_len, host_prefix.data(),
|
| + host_prefix_len) == 0) {
|
| + file_url += UTF8ToWide(url.substr(host_prefix_len));
|
| + }
|
| +
|
| + // Convert the file:/// URL to a path on disk.
|
| + FilePath file_path;
|
| + net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
|
| + return file_path;
|
| +}
|
| +
|
| URLRequestMockHTTPJob::URLRequestMockHTTPJob(URLRequest* request,
|
| const FilePath& file_path)
|
| : URLRequestFileJob(request, file_path) { }
|
|
|