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

Side by Side Diff: chrome/browser/automation/url_request_mock_http_job.cc

Issue 63011: Monster FilePath patch! (Closed)
Patch Set: sync with trunk Created 11 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/automation/url_request_mock_net_error_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/automation/url_request_mock_http_job.h" 5 #include "chrome/browser/automation/url_request_mock_http_job.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 14 matching lines...) Expand all
25 // Fix up the url to be the file url we're loading from disk. 25 // Fix up the url to be the file url we're loading from disk.
26 std::string host_prefix("http://"); 26 std::string host_prefix("http://");
27 host_prefix.append(kMockHostname); 27 host_prefix.append(kMockHostname);
28 size_t host_prefix_len = host_prefix.length(); 28 size_t host_prefix_len = host_prefix.length();
29 if (url.compare(0, host_prefix_len, host_prefix.data(), 29 if (url.compare(0, host_prefix_len, host_prefix.data(),
30 host_prefix_len) == 0) { 30 host_prefix_len) == 0) {
31 file_url += UTF8ToWide(url.substr(host_prefix_len)); 31 file_url += UTF8ToWide(url.substr(host_prefix_len));
32 } 32 }
33 33
34 // Convert the file:/// URL to a path on disk. 34 // Convert the file:/// URL to a path on disk.
35 std::wstring file_path; 35 FilePath file_path;
36 net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path); 36 net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
37 return new URLRequestMockHTTPJob(request, 37 return new URLRequestMockHTTPJob(request, file_path);
38 FilePath::FromWStringHack(file_path));
39 } 38 }
40 39
41 /* static */ 40 /* static */
42 void URLRequestMockHTTPJob::AddUITestUrls(const std::wstring& base_path) { 41 void URLRequestMockHTTPJob::AddUITestUrls(const std::wstring& base_path) {
43 base_path_ = base_path; 42 base_path_ = base_path;
44 43
45 // Add kMockHostname to URLRequestFilter. 44 // Add kMockHostname to URLRequestFilter.
46 URLRequestFilter* filter = URLRequestFilter::GetInstance(); 45 URLRequestFilter* filter = URLRequestFilter::GetInstance();
47 filter->AddHostnameHandler("http", kMockHostname, 46 filter->AddHostnameHandler("http", kMockHostname,
48 URLRequestMockHTTPJob::Factory); 47 URLRequestMockHTTPJob::Factory);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 net::HttpResponseInfo info; 83 net::HttpResponseInfo info;
85 GetResponseInfoConst(&info); 84 GetResponseInfoConst(&info);
86 return info.headers && info.headers->GetMimeType(mime_type); 85 return info.headers && info.headers->GetMimeType(mime_type);
87 } 86 }
88 87
89 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { 88 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) {
90 net::HttpResponseInfo info; 89 net::HttpResponseInfo info;
91 GetResponseInfo(&info); 90 GetResponseInfo(&info);
92 return info.headers && info.headers->GetCharset(charset); 91 return info.headers && info.headers->GetCharset(charset);
93 } 92 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/url_request_mock_net_error_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698