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

Side by Side Diff: net/base/net_util.cc

Issue 399068: Move base64 from 'net/base' into 'base'. (Closed)
Patch Set: rebase Created 11 years 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 | « net/base/data_url.cc ('k') | net/base/sdch_manager.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <map> 8 #include <map>
9 #include <unicode/ucnv.h> 9 #include <unicode/ucnv.h>
10 #include <unicode/uidna.h> 10 #include <unicode/uidna.h>
11 #include <unicode/ulocdata.h> 11 #include <unicode/ulocdata.h>
12 #include <unicode/uniset.h> 12 #include <unicode/uniset.h>
13 #include <unicode/uscript.h> 13 #include <unicode/uscript.h>
14 #include <unicode/uset.h> 14 #include <unicode/uset.h>
15 15
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 #include <windows.h> 19 #include <windows.h>
20 #include <winsock2.h> 20 #include <winsock2.h>
21 #include <ws2tcpip.h> 21 #include <ws2tcpip.h>
22 #include <wspiapi.h> // Needed for Win2k compat. 22 #include <wspiapi.h> // Needed for Win2k compat.
23 #elif defined(OS_POSIX) 23 #elif defined(OS_POSIX)
24 #include <netdb.h> 24 #include <netdb.h>
25 #include <sys/socket.h> 25 #include <sys/socket.h>
26 #include <fcntl.h> 26 #include <fcntl.h>
27 #endif 27 #endif
28 28
29 #include "base/base64.h"
29 #include "base/basictypes.h" 30 #include "base/basictypes.h"
30 #include "base/file_path.h" 31 #include "base/file_path.h"
31 #include "base/file_util.h" 32 #include "base/file_util.h"
32 #include "base/i18n/file_util_icu.h" 33 #include "base/i18n/file_util_icu.h"
33 #include "base/i18n/icu_string_conversions.h" 34 #include "base/i18n/icu_string_conversions.h"
34 #include "base/i18n/time_formatting.h" 35 #include "base/i18n/time_formatting.h"
35 #include "base/json/string_escape.h" 36 #include "base/json/string_escape.h"
36 #include "base/lock.h" 37 #include "base/lock.h"
37 #include "base/logging.h" 38 #include "base/logging.h"
38 #include "base/message_loop.h" 39 #include "base/message_loop.h"
39 #include "base/path_service.h" 40 #include "base/path_service.h"
40 #include "base/singleton.h" 41 #include "base/singleton.h"
41 #include "base/stl_util-inl.h" 42 #include "base/stl_util-inl.h"
42 #include "base/string_piece.h" 43 #include "base/string_piece.h"
43 #include "base/string_tokenizer.h" 44 #include "base/string_tokenizer.h"
44 #include "base/string_util.h" 45 #include "base/string_util.h"
45 #include "base/sys_string_conversions.h" 46 #include "base/sys_string_conversions.h"
46 #include "base/time.h" 47 #include "base/time.h"
47 #include "base/utf_offset_string_conversions.h" 48 #include "base/utf_offset_string_conversions.h"
48 #include "grit/net_resources.h" 49 #include "grit/net_resources.h"
49 #include "googleurl/src/gurl.h" 50 #include "googleurl/src/gurl.h"
50 #include "googleurl/src/url_canon.h" 51 #include "googleurl/src/url_canon.h"
51 #include "googleurl/src/url_parse.h" 52 #include "googleurl/src/url_parse.h"
52 #include "net/base/escape.h" 53 #include "net/base/escape.h"
53 #include "net/base/net_module.h" 54 #include "net/base/net_module.h"
54 #if defined(OS_WIN) 55 #if defined(OS_WIN)
55 #include "net/base/winsock_init.h" 56 #include "net/base/winsock_init.h"
56 #endif 57 #endif
57 #include "net/base/base64.h"
58 #include "unicode/datefmt.h" 58 #include "unicode/datefmt.h"
59 59
60 60
61 using base::Time; 61 using base::Time;
62 62
63 namespace { 63 namespace {
64 64
65 // what we prepend to get a file URL 65 // what we prepend to get a file URL
66 static const FilePath::CharType kFileURLPrefix[] = 66 static const FilePath::CharType kFileURLPrefix[] =
67 FILE_PATH_LITERAL("file:///"); 67 FILE_PATH_LITERAL("file:///");
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 output->swap(temp); 219 output->swap(temp);
220 return true; 220 return true;
221 } 221 }
222 222
223 enum RFC2047EncodingType {Q_ENCODING, B_ENCODING}; 223 enum RFC2047EncodingType {Q_ENCODING, B_ENCODING};
224 bool DecodeBQEncoding(const std::string& part, RFC2047EncodingType enc_type, 224 bool DecodeBQEncoding(const std::string& part, RFC2047EncodingType enc_type,
225 const std::string& charset, std::string* output) { 225 const std::string& charset, std::string* output) {
226 std::string decoded; 226 std::string decoded;
227 if (enc_type == B_ENCODING) { 227 if (enc_type == B_ENCODING) {
228 if (!net::Base64Decode(part, &decoded)) { 228 if (!base::Base64Decode(part, &decoded)) {
229 return false; 229 return false;
230 } 230 }
231 } else { 231 } else {
232 if (!QPDecode(part, &decoded)) { 232 if (!QPDecode(part, &decoded)) {
233 return false; 233 return false;
234 } 234 }
235 } 235 }
236 236
237 UErrorCode err = U_ZERO_ERROR; 237 UErrorCode err = U_ZERO_ERROR;
238 UConverter* converter(ucnv_open(charset.c_str(), &err)); 238 UConverter* converter(ucnv_open(charset.c_str(), &err));
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 if (length > 0) 1530 if (length > 0)
1531 ports.insert(StringToInt(WideToASCII( 1531 ports.insert(StringToInt(WideToASCII(
1532 allowed_ports.substr(last, length)))); 1532 allowed_ports.substr(last, length))));
1533 last = i + 1; 1533 last = i + 1;
1534 } 1534 }
1535 } 1535 }
1536 explicitly_allowed_ports = ports; 1536 explicitly_allowed_ports = ports;
1537 } 1537 }
1538 1538
1539 } // namespace net 1539 } // namespace net
OLDNEW
« no previous file with comments | « net/base/data_url.cc ('k') | net/base/sdch_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698