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

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: Windows. :( 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 FILETIME result;
156 result.dwHighDateTime = std::numeric_limits<int>::max();
157 result.dwLowDateTime = std::numeric_limits<int>::max();
158 return result;
159 }
148 FILETIME utc_ft; 160 FILETIME utc_ft;
149 MicrosecondsToFileTime(us_, &utc_ft); 161 MicrosecondsToFileTime(us_, &utc_ft);
150 return utc_ft; 162 return utc_ft;
151 } 163 }
152 164
153 // static 165 // static
154 void Time::EnableHighResolutionTimer(bool enable) { 166 void Time::EnableHighResolutionTimer(bool enable) {
155 // Test for single-threaded access. 167 // Test for single-threaded access.
156 static PlatformThreadId my_thread = PlatformThread::CurrentId(); 168 static PlatformThreadId my_thread = PlatformThread::CurrentId();
157 DCHECK(PlatformThread::CurrentId() == my_thread); 169 DCHECK(PlatformThread::CurrentId() == my_thread);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); 479 return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
468 } 480 }
469 481
470 // TimeDelta ------------------------------------------------------------------ 482 // TimeDelta ------------------------------------------------------------------
471 483
472 // static 484 // static
473 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { 485 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) {
474 return TimeDelta( 486 return TimeDelta(
475 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value)); 487 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value));
476 } 488 }
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