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

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

Issue 6246036: FilePath: Remove most of ToWStringHack, adding a LossyDisplayName() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/net/url_request_mock_http_job.h" 5 #include "chrome/browser/net/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 "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 24 matching lines...) Expand all
35 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); 35 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance();
36 filter->AddHostnameHandler("http", kMockHostname, 36 filter->AddHostnameHandler("http", kMockHostname,
37 URLRequestMockHTTPJob::Factory); 37 URLRequestMockHTTPJob::Factory);
38 } 38 }
39 39
40 /* static */ 40 /* static */
41 GURL URLRequestMockHTTPJob::GetMockUrl(const FilePath& path) { 41 GURL URLRequestMockHTTPJob::GetMockUrl(const FilePath& path) {
42 std::string url = "http://"; 42 std::string url = "http://";
43 url.append(kMockHostname); 43 url.append(kMockHostname);
44 url.append("/"); 44 url.append("/");
45 url.append(WideToUTF8(path.ToWStringHack())); 45 url.append(UTF16ToUTF8(path.LossyDisplayName()));
46 return GURL(url); 46 return GURL(url);
47 } 47 }
48 48
49 /* static */ 49 /* static */
50 GURL URLRequestMockHTTPJob::GetMockViewSourceUrl(const FilePath& path) { 50 GURL URLRequestMockHTTPJob::GetMockViewSourceUrl(const FilePath& path) {
51 std::string url = chrome::kViewSourceScheme; 51 std::string url = chrome::kViewSourceScheme;
52 url.append(":"); 52 url.append(":");
53 url.append(GetMockUrl(path).spec()); 53 url.append(GetMockUrl(path).spec());
54 return GURL(url); 54 return GURL(url);
55 } 55 }
56 56
57 /* static */ 57 /* static */
58 FilePath URLRequestMockHTTPJob::GetOnDiskPath(const FilePath& base_path, 58 FilePath URLRequestMockHTTPJob::GetOnDiskPath(const FilePath& base_path,
59 net::URLRequest* request, 59 net::URLRequest* request,
60 const std::string& scheme) { 60 const std::string& scheme) {
61 std::string file_url("file:///"); 61 std::string file_url("file:///");
62 file_url += WideToUTF8(base_path.ToWStringHack()); 62 file_url + UTF16ToUTF8(base_path.LossyDisplayName());
63 file_url += request->url().path(); 63 file_url += request->url().path();
64 64
65 // Convert the file:/// URL to a path on disk. 65 // Convert the file:/// URL to a path on disk.
66 FilePath file_path; 66 FilePath file_path;
67 net::FileURLToFilePath(GURL(file_url), &file_path); 67 net::FileURLToFilePath(GURL(file_url), &file_path);
68 return file_path; 68 return file_path;
69 } 69 }
70 70
71 URLRequestMockHTTPJob::URLRequestMockHTTPJob(net::URLRequest* request, 71 URLRequestMockHTTPJob::URLRequestMockHTTPJob(net::URLRequest* request,
72 const FilePath& file_path) 72 const FilePath& file_path)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 net::HttpResponseInfo info; 106 net::HttpResponseInfo info;
107 GetResponseInfoConst(&info); 107 GetResponseInfoConst(&info);
108 return info.headers && info.headers->GetMimeType(mime_type); 108 return info.headers && info.headers->GetMimeType(mime_type);
109 } 109 }
110 110
111 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { 111 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) {
112 net::HttpResponseInfo info; 112 net::HttpResponseInfo info;
113 GetResponseInfo(&info); 113 GetResponseInfo(&info);
114 return info.headers && info.headers->GetCharset(charset); 114 return info.headers && info.headers->GetCharset(charset);
115 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698