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

Unified Diff: net/base/filename_util.cc

Issue 1068793002: Fixed "blocking io" from FixupPath on UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed "blocking io" from FixupURL on UI thread Created 5 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 side-by-side diff with in-line comments
Download patch
« net/base/filename_util.h ('K') | « net/base/filename_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/filename_util.cc
diff --git a/net/base/filename_util.cc b/net/base/filename_util.cc
index c9d5fe4b5f2652bb7ab47c57d3cf80fe7ab95b9e..7d60c39683d5eddae48cbf312d582cf89aafb045 100644
--- a/net/base/filename_util.cc
+++ b/net/base/filename_util.cc
@@ -63,6 +63,39 @@ GURL FilePathToFileURL(const base::FilePath& path) {
return GURL(url_string);
}
+GURL FilePathToFileURLNoCWD(const base::FilePath& path) {
+ // Produce a URL like "file:///C:/foo" for a regular file, or
+ // "file://///server/path" for UNC. The URL canonicalizer will fix up the
+ // latter case to be the canonical UNC form: "file://server/path"
+ base::FilePath::StringType url_string(kFileURLPrefix);
+ url_string.append(path.value());
+ // Do replacement of some characters. Since we assume the input is a
+ // literal filename, anything the URL parser might consider special should
+ // be escaped here.
+
+ // must be the first substitution since others will introduce percents as the
+ // escape character
+ ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("%"),
+ FILE_PATH_LITERAL("%25"));
+
+ // semicolon is supposed to be some kind of separator according to RFC 2396
+ ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL(";"),
+ FILE_PATH_LITERAL("%3B"));
+
+ ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("#"),
+ FILE_PATH_LITERAL("%23"));
+
+ ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("?"),
+ FILE_PATH_LITERAL("%3F"));
+
+#if defined(OS_POSIX)
+ ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("\\"),
+ FILE_PATH_LITERAL("%5C"));
+#endif
davidben 2015/04/14 16:26:22 This is too much code to be duplicated. Move thing
+
+ return GURL(url_string);
+}
+
bool FileURLToFilePath(const GURL& url, base::FilePath* file_path) {
*file_path = base::FilePath();
base::FilePath::StringType& file_path_str =
« net/base/filename_util.h ('K') | « net/base/filename_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698