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

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

Issue 42013: Slight code change to make some global variables const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « net/base/mime_util.cc ('k') | net/base/net_util_unittest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <algorithm> 5 #include <algorithm>
6 #include <unicode/ucnv.h> 6 #include <unicode/ucnv.h>
7 #include <unicode/uidna.h> 7 #include <unicode/uidna.h>
8 #include <unicode/ulocdata.h> 8 #include <unicode/ulocdata.h>
9 #include <unicode/uniset.h> 9 #include <unicode/uniset.h>
10 #include <unicode/uscript.h> 10 #include <unicode/uscript.h>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 typename STR::const_iterator end = find(begin, headers.end(), '\n'); 160 typename STR::const_iterator end = find(begin, headers.end(), '\n');
161 161
162 STR ret; 162 STR ret;
163 TrimWhitespace(STR(begin, end), TRIM_ALL, &ret); 163 TrimWhitespace(STR(begin, end), TRIM_ALL, &ret);
164 return ret; 164 return ret;
165 } 165 }
166 166
167 // TODO(jungshik): We have almost identical hex-decoding code else where. 167 // TODO(jungshik): We have almost identical hex-decoding code else where.
168 // Consider refactoring and moving it somewhere(base?). Bug 1224311 168 // Consider refactoring and moving it somewhere(base?). Bug 1224311
169 inline bool IsHexDigit(unsigned char c) { 169 inline bool IsHexDigit(unsigned char c) {
170 return (('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f')); 170 return (('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
171 ('a' <= c && c <= 'f'));
171 } 172 }
172 173
173 inline unsigned char HexToInt(unsigned char c) { 174 inline unsigned char HexToInt(unsigned char c) {
174 DCHECK(IsHexDigit(c)); 175 DCHECK(IsHexDigit(c));
175 static unsigned char kOffset[4] = {0, 0x30u, 0x37u, 0x57u}; 176 static unsigned char kOffset[4] = {0, 0x30u, 0x37u, 0x57u};
176 return c - kOffset[(c >> 5) & 3]; 177 return c - kOffset[(c >> 5) & 3];
177 } 178 }
178 179
179 // Similar to Base64Decode. Decodes a Q-encoded string to a sequence 180 // Similar to Base64Decode. Decodes a Q-encoded string to a sequence
180 // of bytes. If input is invalid, return false. 181 // of bytes. If input is invalid, return false.
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 StringTokenizer t(languages_list, ","); 558 StringTokenizer t(languages_list, ",");
558 while (t.GetNext()) { 559 while (t.GetNext()) {
559 std::string lang = t.token(); 560 std::string lang = t.token();
560 status = U_ZERO_ERROR; 561 status = U_ZERO_ERROR;
561 // TODO(jungshik) Cache exemplar sets for locales. 562 // TODO(jungshik) Cache exemplar sets for locales.
562 ULocaleData* uld = ulocdata_open(lang.c_str(), &status); 563 ULocaleData* uld = ulocdata_open(lang.c_str(), &status);
563 // TODO(jungshik) Turn this check on when the ICU data file is 564 // TODO(jungshik) Turn this check on when the ICU data file is
564 // rebuilt with the minimal subset of locale data for languages 565 // rebuilt with the minimal subset of locale data for languages
565 // to which Chrome is not localized but which we offer in the list 566 // to which Chrome is not localized but which we offer in the list
566 // of languages selectable for Accept-Languages. With the rebuilt ICU 567 // of languages selectable for Accept-Languages. With the rebuilt ICU
567 // data, ulocdata_open never should fall back to the default locale. (issue 2078) 568 // data, ulocdata_open never should fall back to the default locale.
569 // (issue 2078)
568 // DCHECK(U_SUCCESS(status) && status != U_USING_DEFAULT_WARNING); 570 // DCHECK(U_SUCCESS(status) && status != U_USING_DEFAULT_WARNING);
569 if (U_SUCCESS(status) && status != U_USING_DEFAULT_WARNING) { 571 if (U_SUCCESS(status) && status != U_USING_DEFAULT_WARNING) {
570 // Should we use auxiliary set, instead? 572 // Should we use auxiliary set, instead?
571 ulocdata_getExemplarSet(uld, lang_set, 0, ULOCDATA_ES_STANDARD, &status); 573 ulocdata_getExemplarSet(uld, lang_set, 0, ULOCDATA_ES_STANDARD, &status);
572 ulocdata_close(uld); 574 ulocdata_close(uld);
573 if (U_SUCCESS(status)) { 575 if (U_SUCCESS(status)) {
574 UnicodeSet* allowed_characters = 576 UnicodeSet* allowed_characters =
575 reinterpret_cast<UnicodeSet*>(lang_set); 577 reinterpret_cast<UnicodeSet*>(lang_set);
576 // If |lang| is compatible with ASCII Latin letters, add them. 578 // If |lang| is compatible with ASCII Latin letters, add them.
577 if (IsCompatibleWithASCIILetters(lang)) 579 if (IsCompatibleWithASCIILetters(lang))
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 char buffer[256]; 1048 char buffer[256];
1047 int result = gethostname(buffer, sizeof(buffer)); 1049 int result = gethostname(buffer, sizeof(buffer));
1048 if (result != 0) { 1050 if (result != 0) {
1049 DLOG(INFO) << "gethostname() failed with " << result; 1051 DLOG(INFO) << "gethostname() failed with " << result;
1050 buffer[0] = '\0'; 1052 buffer[0] = '\0';
1051 } 1053 }
1052 return std::string(buffer); 1054 return std::string(buffer);
1053 } 1055 }
1054 1056
1055 } // namespace net 1057 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mime_util.cc ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698