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

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: DWORD. 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
« no previous file with comments | « 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 (ft.dwHighDateTime == std::numeric_limits<DWORD>::max() &&
147 ft.dwLowDateTime == std::numeric_limits<DWORD>::max())
148 return Max();
144 return Time(FileTimeToMicroseconds(ft)); 149 return Time(FileTimeToMicroseconds(ft));
145 } 150 }
146 151
147 FILETIME Time::ToFileTime() const { 152 FILETIME Time::ToFileTime() const {
153 if (is_null())
154 return bit_cast<FILETIME, int64>(0);
155 if (is_max()) {
156 FILETIME result;
157 result.dwHighDateTime = std::numeric_limits<DWORD>::max();
158 result.dwLowDateTime = std::numeric_limits<DWORD>::max();
159 return result;
160 }
148 FILETIME utc_ft; 161 FILETIME utc_ft;
149 MicrosecondsToFileTime(us_, &utc_ft); 162 MicrosecondsToFileTime(us_, &utc_ft);
150 return utc_ft; 163 return utc_ft;
151 } 164 }
152 165
153 // static 166 // static
154 void Time::EnableHighResolutionTimer(bool enable) { 167 void Time::EnableHighResolutionTimer(bool enable) {
155 // Test for single-threaded access. 168 // Test for single-threaded access.
156 static PlatformThreadId my_thread = PlatformThread::CurrentId(); 169 static PlatformThreadId my_thread = PlatformThread::CurrentId();
157 DCHECK(PlatformThread::CurrentId() == my_thread); 170 DCHECK(PlatformThread::CurrentId() == my_thread);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); 480 return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
468 } 481 }
469 482
470 // TimeDelta ------------------------------------------------------------------ 483 // TimeDelta ------------------------------------------------------------------
471 484
472 // static 485 // static
473 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { 486 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) {
474 return TimeDelta( 487 return TimeDelta(
475 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value)); 488 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value));
476 } 489 }
OLDNEW
« no previous file with comments | « base/time_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698