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

Side by Side Diff: base/time_win.cc

Issue 10916089: Fixing Time::Max()'s behavior with Time::ToTimeT() and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scary casting. Created 8 years, 3 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 | Annotate | Revision Log
« base/time_unittest.cc ('K') | « base/time_unittest.cc ('k') | no next file » | 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 5
6 // Windows Timer Primer 6 // Windows Timer Primer
7 // 7 //
8 // A good article: http://www.ddj.com/windows/184416651 8 // A good article: http://www.ddj.com/windows/184416651
9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258
10 // 10 //
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // static 135 // static
136 Time Time::NowFromSystemTime() { 136 Time Time::NowFromSystemTime() {
137 // Force resync. 137 // Force resync.
138 InitializeClock(); 138 InitializeClock();
139 return Time(initial_time); 139 return Time(initial_time);
140 } 140 }
141 141
142 // static 142 // static
143 Time Time::FromFileTime(FILETIME ft) { 143 Time Time::FromFileTime(FILETIME ft) {
144 if (bit_cast<int64, FILETIME>(ft) == 0)
145 return Time();
146 if (bit_cast<int64, FILETIME>(ft) == std::numeric_limits<int64>::max())
147 return Max();
144 return Time(FileTimeToMicroseconds(ft)); 148 return Time(FileTimeToMicroseconds(ft));
145 } 149 }
146 150
147 FILETIME Time::ToFileTime() const { 151 FILETIME Time::ToFileTime() const {
152 if (is_null())
153 return bit_cast<FILETIME, int64>(0);
154 if (is_max())
155 return bit_cast<FILETIME, int64>(std::numeric_limits<int64>::max());
148 FILETIME utc_ft; 156 FILETIME utc_ft;
149 MicrosecondsToFileTime(us_, &utc_ft); 157 MicrosecondsToFileTime(us_, &utc_ft);
150 return utc_ft; 158 return utc_ft;
151 } 159 }
152 160
153 // static 161 // static
154 void Time::EnableHighResolutionTimer(bool enable) { 162 void Time::EnableHighResolutionTimer(bool enable) {
155 // Test for single-threaded access. 163 // Test for single-threaded access.
156 static PlatformThreadId my_thread = PlatformThread::CurrentId(); 164 static PlatformThreadId my_thread = PlatformThread::CurrentId();
157 DCHECK(PlatformThread::CurrentId() == my_thread); 165 DCHECK(PlatformThread::CurrentId() == my_thread);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); 475 return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
468 } 476 }
469 477
470 // TimeDelta ------------------------------------------------------------------ 478 // TimeDelta ------------------------------------------------------------------
471 479
472 // static 480 // static
473 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { 481 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) {
474 return TimeDelta( 482 return TimeDelta(
475 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value)); 483 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value));
476 } 484 }
OLDNEW
« base/time_unittest.cc ('K') | « base/time_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698