OLD | NEW |
1 // Copyright (c) 2011 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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "unicode/numfmt.h" | 14 #include "unicode/numfmt.h" |
15 #include "unicode/ustring.h" | 15 #include "unicode/ustring.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
| 21 // A simple wrapper around icu::NumberFormat that allows for resetting it |
| 22 // (as LazyInstance does not). |
21 struct NumberFormatWrapper { | 23 struct NumberFormatWrapper { |
22 NumberFormatWrapper() { | 24 NumberFormatWrapper() { |
23 Reset(); | 25 Reset(); |
24 } | 26 } |
25 | 27 |
26 void Reset() { | 28 void Reset() { |
27 // There's no ICU call to destroy a NumberFormat object other than | 29 // There's no ICU call to destroy a NumberFormat object other than |
28 // operator delete, so use the default Delete, which calls operator delete. | 30 // operator delete, so use the default Delete, which calls operator delete. |
29 // This can cause problems if a different allocator is used by this file | 31 // This can cause problems if a different allocator is used by this file |
30 // than by ICU. | 32 // than by ICU. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 namespace testing { | 78 namespace testing { |
77 | 79 |
78 void ResetFormatters() { | 80 void ResetFormatters() { |
79 g_number_format_int.Get().Reset(); | 81 g_number_format_int.Get().Reset(); |
80 g_number_format_float.Get().Reset(); | 82 g_number_format_float.Get().Reset(); |
81 } | 83 } |
82 | 84 |
83 } // namespace testing | 85 } // namespace testing |
84 | 86 |
85 } // namespace base | 87 } // namespace base |
OLD | NEW |