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 "base/i18n/number_formatting.h" | 5 #include "base/i18n/number_formatting.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 // This can cause problems if a different allocator is used by this file | 35 // This can cause problems if a different allocator is used by this file |
36 // than by ICU. | 36 // than by ICU. |
37 UErrorCode status = U_ZERO_ERROR; | 37 UErrorCode status = U_ZERO_ERROR; |
38 number_format.reset(icu::NumberFormat::createInstance(status)); | 38 number_format.reset(icu::NumberFormat::createInstance(status)); |
39 DCHECK(U_SUCCESS(status)); | 39 DCHECK(U_SUCCESS(status)); |
40 } | 40 } |
41 | 41 |
42 std::unique_ptr<icu::NumberFormat> number_format; | 42 std::unique_ptr<icu::NumberFormat> number_format; |
43 }; | 43 }; |
44 | 44 |
45 LazyInstance<NumberFormatWrapper> g_number_format_int = | 45 LazyInstance<NumberFormatWrapper>::DestructorAtExit g_number_format_int = |
46 LAZY_INSTANCE_INITIALIZER; | 46 LAZY_INSTANCE_INITIALIZER; |
47 LazyInstance<NumberFormatWrapper> g_number_format_float = | 47 LazyInstance<NumberFormatWrapper>::DestructorAtExit g_number_format_float = |
48 LAZY_INSTANCE_INITIALIZER; | 48 LAZY_INSTANCE_INITIALIZER; |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 string16 FormatNumber(int64_t number) { | 52 string16 FormatNumber(int64_t number) { |
53 icu::NumberFormat* number_format = | 53 icu::NumberFormat* number_format = |
54 g_number_format_int.Get().number_format.get(); | 54 g_number_format_int.Get().number_format.get(); |
55 | 55 |
56 if (!number_format) { | 56 if (!number_format) { |
57 // As a fallback, just return the raw number in a string. | 57 // As a fallback, just return the raw number in a string. |
(...skipping 29 matching lines...) Expand all Loading... |
87 namespace testing { | 87 namespace testing { |
88 | 88 |
89 void ResetFormatters() { | 89 void ResetFormatters() { |
90 g_number_format_int.Get().Reset(); | 90 g_number_format_int.Get().Reset(); |
91 g_number_format_float.Get().Reset(); | 91 g_number_format_float.Get().Reset(); |
92 } | 92 } |
93 | 93 |
94 } // namespace testing | 94 } // namespace testing |
95 | 95 |
96 } // namespace base | 96 } // namespace base |
OLD | NEW |