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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 bool replace_trailing) { | 760 bool replace_trailing) { |
761 const base::FilePath::CharType kReplace[] = FILE_PATH_LITERAL("-"); | 761 const base::FilePath::CharType kReplace[] = FILE_PATH_LITERAL("-"); |
762 if (filename->empty()) | 762 if (filename->empty()) |
763 return; | 763 return; |
764 if (replace_trailing) { | 764 if (replace_trailing) { |
765 // Handle CreateFile() stripping trailing dots and spaces on filenames | 765 // Handle CreateFile() stripping trailing dots and spaces on filenames |
766 // http://support.microsoft.com/kb/115827 | 766 // http://support.microsoft.com/kb/115827 |
767 size_t length = filename->size(); | 767 size_t length = filename->size(); |
768 size_t pos = filename->find_last_not_of(FILE_PATH_LITERAL(" .")); | 768 size_t pos = filename->find_last_not_of(FILE_PATH_LITERAL(" .")); |
769 filename->resize((pos == std::string::npos) ? 0 : (pos + 1)); | 769 filename->resize((pos == std::string::npos) ? 0 : (pos + 1)); |
770 TrimWhitespace(*filename, TRIM_TRAILING, filename); | 770 base::TrimWhitespace(*filename, base::TRIM_TRAILING, filename); |
771 if (filename->empty()) | 771 if (filename->empty()) |
772 return; | 772 return; |
773 size_t trimmed = length - filename->size(); | 773 size_t trimmed = length - filename->size(); |
774 if (trimmed) | 774 if (trimmed) |
775 filename->insert(filename->end(), trimmed, kReplace[0]); | 775 filename->insert(filename->end(), trimmed, kReplace[0]); |
776 } | 776 } |
777 base::TrimString(*filename, FILE_PATH_LITERAL("."), filename); | 777 base::TrimString(*filename, FILE_PATH_LITERAL("."), filename); |
778 if (filename->empty()) | 778 if (filename->empty()) |
779 return; | 779 return; |
780 // Replace any path information by changing path separators. | 780 // Replace any path information by changing path separators. |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 std::string::const_iterator begin = | 1051 std::string::const_iterator begin = |
1052 std::search(headers.begin(), headers.end(), match.begin(), match.end(), | 1052 std::search(headers.begin(), headers.end(), match.begin(), match.end(), |
1053 base::CaseInsensitiveCompareASCII<char>()); | 1053 base::CaseInsensitiveCompareASCII<char>()); |
1054 | 1054 |
1055 if (begin == headers.end()) | 1055 if (begin == headers.end()) |
1056 return std::string(); | 1056 return std::string(); |
1057 | 1057 |
1058 begin += match.length(); | 1058 begin += match.length(); |
1059 | 1059 |
1060 std::string ret; | 1060 std::string ret; |
1061 TrimWhitespace(std::string(begin, std::find(begin, headers.end(), '\n')), | 1061 base::TrimWhitespace(std::string(begin, |
1062 TRIM_ALL, &ret); | 1062 std::find(begin, headers.end(), '\n')), |
| 1063 base::TRIM_ALL, &ret); |
1063 return ret; | 1064 return ret; |
1064 } | 1065 } |
1065 | 1066 |
1066 base::string16 IDNToUnicode(const std::string& host, | 1067 base::string16 IDNToUnicode(const std::string& host, |
1067 const std::string& languages) { | 1068 const std::string& languages) { |
1068 return IDNToUnicodeWithOffsets(host, languages, NULL); | 1069 return IDNToUnicodeWithOffsets(host, languages, NULL); |
1069 } | 1070 } |
1070 | 1071 |
1071 std::string CanonicalizeHost(const std::string& host, | 1072 std::string CanonicalizeHost(const std::string& host, |
1072 url_canon::CanonHostInfo* host_info) { | 1073 url_canon::CanonHostInfo* host_info) { |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 } | 2222 } |
2222 return a1.size() * CHAR_BIT; | 2223 return a1.size() * CHAR_BIT; |
2223 } | 2224 } |
2224 | 2225 |
2225 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 2226 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
2226 IPAddressNumber all_ones(mask.size(), 0xFF); | 2227 IPAddressNumber all_ones(mask.size(), 0xFF); |
2227 return CommonPrefixLength(mask, all_ones); | 2228 return CommonPrefixLength(mask, all_ones); |
2228 } | 2229 } |
2229 | 2230 |
2230 } // namespace net | 2231 } // namespace net |
OLD | NEW |