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

Side by Side Diff: chrome/common/time_format.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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 | « chrome/common/profiling.cc ('k') | chrome/default_plugin/install_dialog.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/time_format.h" 5 #include "chrome/common/time_format.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 std::vector<icu::PluralFormat*> time_left_formatter_; 174 std::vector<icu::PluralFormat*> time_left_formatter_;
175 std::vector<icu::PluralFormat*> time_elapsed_formatter_; 175 std::vector<icu::PluralFormat*> time_elapsed_formatter_;
176 static void BuildFormats(FormatType format_type, 176 static void BuildFormats(FormatType format_type,
177 std::vector<icu::PluralFormat*>* time_formats); 177 std::vector<icu::PluralFormat*>* time_formats);
178 static icu::PluralFormat* createFallbackFormat( 178 static icu::PluralFormat* createFallbackFormat(
179 const icu::PluralRules& rules, int index, FormatType format_type); 179 const icu::PluralRules& rules, int index, FormatType format_type);
180 180
181 DISALLOW_COPY_AND_ASSIGN(TimeFormatter); 181 DISALLOW_COPY_AND_ASSIGN(TimeFormatter);
182 }; 182 };
183 183
184 static base::LazyInstance<TimeFormatter> g_time_formatter( 184 static base::LazyInstance<TimeFormatter> g_time_formatter =
185 base::LINKER_INITIALIZED); 185 LAZY_INSTANCE_INITIALIZER;
186 186
187 void TimeFormatter::BuildFormats( 187 void TimeFormatter::BuildFormats(
188 FormatType format_type, std::vector<icu::PluralFormat*>* time_formats) { 188 FormatType format_type, std::vector<icu::PluralFormat*>* time_formats) {
189 static const icu::UnicodeString kKeywords[] = { 189 static const icu::UnicodeString kKeywords[] = {
190 UNICODE_STRING_SIMPLE("other"), UNICODE_STRING_SIMPLE("one"), 190 UNICODE_STRING_SIMPLE("other"), UNICODE_STRING_SIMPLE("one"),
191 UNICODE_STRING_SIMPLE("zero"), UNICODE_STRING_SIMPLE("two"), 191 UNICODE_STRING_SIMPLE("zero"), UNICODE_STRING_SIMPLE("two"),
192 UNICODE_STRING_SIMPLE("few"), UNICODE_STRING_SIMPLE("many") 192 UNICODE_STRING_SIMPLE("few"), UNICODE_STRING_SIMPLE("many")
193 }; 193 };
194 UErrorCode err = U_ZERO_ERROR; 194 UErrorCode err = U_ZERO_ERROR;
195 scoped_ptr<icu::PluralRules> rules( 195 scoped_ptr<icu::PluralRules> rules(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 // Filter out "today" and "yesterday" 329 // Filter out "today" and "yesterday"
330 if (time >= midnight_today) 330 if (time >= midnight_today)
331 return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY); 331 return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY);
332 else if (time >= midnight_today - 332 else if (time >= midnight_today -
333 TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay)) 333 TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay))
334 return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY); 334 return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY);
335 335
336 return string16(); 336 return string16();
337 } 337 }
OLDNEW
« no previous file with comments | « chrome/common/profiling.cc ('k') | chrome/default_plugin/install_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698