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

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

Issue 1230093002: Get a descriptive error name from ICU Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | url/url_canon_icu.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) 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 <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
11 #include "base/json/string_escape.h" 11 #include "base/json/string_escape.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/strings/string_tokenizer.h" 16 #include "base/strings/string_tokenizer.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_offset_string_conversions.h" 18 #include "base/strings/utf_offset_string_conversions.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 #include "third_party/icu/source/common/unicode/uidna.h" 22 #include "third_party/icu/source/common/unicode/uidna.h"
23 #include "third_party/icu/source/common/unicode/uniset.h" 23 #include "third_party/icu/source/common/unicode/uniset.h"
24 #include "third_party/icu/source/common/unicode/uscript.h" 24 #include "third_party/icu/source/common/unicode/uscript.h"
25 #include "third_party/icu/source/common/unicode/uset.h" 25 #include "third_party/icu/source/common/unicode/uset.h"
26 #include "third_party/icu/source/common/unicode/utypes.h"
26 #include "third_party/icu/source/i18n/unicode/datefmt.h" 27 #include "third_party/icu/source/i18n/unicode/datefmt.h"
27 #include "third_party/icu/source/i18n/unicode/regex.h" 28 #include "third_party/icu/source/i18n/unicode/regex.h"
28 #include "third_party/icu/source/i18n/unicode/ulocdata.h" 29 #include "third_party/icu/source/i18n/unicode/ulocdata.h"
29 30
30 using base::Time; 31 using base::Time;
31 32
32 namespace net { 33 namespace net {
33 34
34 namespace { 35 namespace {
35 36
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // It also closely matches what IE 10 does except for the BiDi check ( 292 // It also closely matches what IE 10 does except for the BiDi check (
292 // http://goo.gl/3XBhqw ). 293 // http://goo.gl/3XBhqw ).
293 // See http://http://unicode.org/reports/tr46/ and references therein 294 // See http://http://unicode.org/reports/tr46/ and references therein
294 // for more details. 295 // for more details.
295 struct UIDNAWrapper { 296 struct UIDNAWrapper {
296 UIDNAWrapper() { 297 UIDNAWrapper() {
297 UErrorCode err = U_ZERO_ERROR; 298 UErrorCode err = U_ZERO_ERROR;
298 // TODO(jungshik): Change options as different parties (browsers, 299 // TODO(jungshik): Change options as different parties (browsers,
299 // registrars, search engines) converge toward a consensus. 300 // registrars, search engines) converge toward a consensus.
300 value = uidna_openUTS46(UIDNA_CHECK_BIDI, &err); 301 value = uidna_openUTS46(UIDNA_CHECK_BIDI, &err);
301 if (U_FAILURE(err)) 302 if (U_FAILURE(err)) {
303 CHECK(false) << "failed to open UTS46 data with error: "
304 << u_errorName(err);
302 value = NULL; 305 value = NULL;
306 }
303 } 307 }
304 308
305 UIDNA* value; 309 UIDNA* value;
306 }; 310 };
307 311
308 static base::LazyInstance<UIDNAWrapper>::Leaky 312 static base::LazyInstance<UIDNAWrapper>::Leaky
309 g_uidna = LAZY_INSTANCE_INITIALIZER; 313 g_uidna = LAZY_INSTANCE_INITIALIZER;
310 314
311 // Converts one component of a host (between dots) to IDN if safe. The result 315 // Converts one component of a host (between dots) to IDN if safe. The result
312 // will be APPENDED to the given output string and will be the same as the input 316 // will be APPENDED to the given output string and will be the same as the input
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 if (offset_for_adjustment) 834 if (offset_for_adjustment)
831 offsets.push_back(*offset_for_adjustment); 835 offsets.push_back(*offset_for_adjustment);
832 base::string16 result = FormatUrlWithOffsets(url, languages, format_types, 836 base::string16 result = FormatUrlWithOffsets(url, languages, format_types,
833 unescape_rules, new_parsed, prefix_end, &offsets); 837 unescape_rules, new_parsed, prefix_end, &offsets);
834 if (offset_for_adjustment) 838 if (offset_for_adjustment)
835 *offset_for_adjustment = offsets[0]; 839 *offset_for_adjustment = offsets[0];
836 return result; 840 return result;
837 } 841 }
838 842
839 } // namespace net 843 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | url/url_canon_icu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698