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/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
991 | 991 |
992 size_t GetCountOfExplicitlyAllowedPorts() { | 992 size_t GetCountOfExplicitlyAllowedPorts() { |
993 return g_explicitly_allowed_ports.Get().size(); | 993 return g_explicitly_allowed_ports.Get().size(); |
994 } | 994 } |
995 | 995 |
996 GURL FilePathToFileURL(const base::FilePath& path) { | 996 GURL FilePathToFileURL(const base::FilePath& path) { |
997 // Produce a URL like "file:///C:/foo" for a regular file, or | 997 // Produce a URL like "file:///C:/foo" for a regular file, or |
998 // "file://///server/path" for UNC. The URL canonicalizer will fix up the | 998 // "file://///server/path" for UNC. The URL canonicalizer will fix up the |
999 // latter case to be the canonical UNC form: "file://server/path" | 999 // latter case to be the canonical UNC form: "file://server/path" |
1000 base::FilePath::StringType url_string(kFileURLPrefix); | 1000 base::FilePath::StringType url_string(kFileURLPrefix); |
1001 if (!path.IsAbsolute()) { | |
1002 base::FilePath current_dir; | |
1003 PathService::Get(base::DIR_CURRENT, ¤t_dir); | |
1004 url_string.append(current_dir.value()); | |
1005 url_string.append(1, base::FilePath::kSeparators[0]); | |
wtc
2014/01/21 22:25:36
Nit: you can use push_back to append just one char
| |
1006 } | |
1001 url_string.append(path.value()); | 1007 url_string.append(path.value()); |
1002 | 1008 |
1003 // Now do replacement of some characters. Since we assume the input is a | 1009 // Now do replacement of some characters. Since we assume the input is a |
1004 // literal filename, anything the URL parser might consider special should | 1010 // literal filename, anything the URL parser might consider special should |
1005 // be escaped here. | 1011 // be escaped here. |
1006 | 1012 |
1007 // must be the first substitution since others will introduce percents as the | 1013 // must be the first substitution since others will introduce percents as the |
1008 // escape character | 1014 // escape character |
1009 ReplaceSubstringsAfterOffset(&url_string, 0, | 1015 ReplaceSubstringsAfterOffset(&url_string, 0, |
1010 FILE_PATH_LITERAL("%"), FILE_PATH_LITERAL("%25")); | 1016 FILE_PATH_LITERAL("%"), FILE_PATH_LITERAL("%25")); |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2215 } | 2221 } |
2216 return a1.size() * CHAR_BIT; | 2222 return a1.size() * CHAR_BIT; |
2217 } | 2223 } |
2218 | 2224 |
2219 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 2225 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
2220 IPAddressNumber all_ones(mask.size(), 0xFF); | 2226 IPAddressNumber all_ones(mask.size(), 0xFF); |
2221 return CommonPrefixLength(mask, all_ones); | 2227 return CommonPrefixLength(mask, all_ones); |
2222 } | 2228 } |
2223 | 2229 |
2224 } // namespace net | 2230 } // namespace net |
OLD | NEW |