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

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

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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/metrics_log_manager.cc ('k') | chrome_frame/chrome_tab.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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Anything bigger gets "X days left" 289 // Anything bigger gets "X days left"
290 } else { 290 } else {
291 number = static_cast<int>(delta.ToInternalValue() / 291 number = static_cast<int>(delta.ToInternalValue() /
292 Time::kMicrosecondsPerDay); 292 Time::kMicrosecondsPerDay);
293 time_string = formatters[3]->format(number, error); 293 time_string = formatters[3]->format(number, error);
294 } 294 }
295 295
296 // With the fallback added, this should never fail. 296 // With the fallback added, this should never fail.
297 DCHECK(U_SUCCESS(error)); 297 DCHECK(U_SUCCESS(error));
298 int capacity = time_string.length() + 1; 298 int capacity = time_string.length() + 1;
299 DCHECK_GT(capacity, 1);
299 string16 result; 300 string16 result;
300 time_string.extract(static_cast<UChar*>( 301 time_string.extract(static_cast<UChar*>(WriteInto(&result, capacity)),
301 WriteInto(&result, capacity)),
302 capacity, error); 302 capacity, error);
303 DCHECK(U_SUCCESS(error)); 303 DCHECK(U_SUCCESS(error));
304 return result; 304 return result;
305 } 305 }
306 306
307 // static 307 // static
308 string16 TimeFormat::TimeElapsed(const TimeDelta& delta) { 308 string16 TimeFormat::TimeElapsed(const TimeDelta& delta) {
309 return FormatTimeImpl(delta, FORMAT_ELAPSED); 309 return FormatTimeImpl(delta, FORMAT_ELAPSED);
310 } 310 }
311 311
(...skipping 16 matching lines...) Expand all
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/metrics_log_manager.cc ('k') | chrome_frame/chrome_tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698