OLD | NEW |
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 bool Time::IsHighResolutionTimerInUse() { | 220 bool Time::IsHighResolutionTimerInUse() { |
221 base::AutoLock lock(g_high_res_lock.Get()); | 221 base::AutoLock lock(g_high_res_lock.Get()); |
222 return g_high_res_timer_enabled && g_high_res_timer_count > 0; | 222 return g_high_res_timer_enabled && g_high_res_timer_count > 0; |
223 } | 223 } |
224 | 224 |
225 // static | 225 // static |
226 Time Time::FromExploded(bool is_local, const Exploded& exploded) { | 226 Time Time::FromExploded(bool is_local, const Exploded& exploded) { |
227 // Create the system struct representing our exploded time. It will either be | 227 // Create the system struct representing our exploded time. It will either be |
228 // in local time or UTC. | 228 // in local time or UTC. |
229 SYSTEMTIME st; | 229 SYSTEMTIME st; |
230 st.wYear = exploded.year; | 230 st.wYear = static_cast<WORD>(exploded.year); |
231 st.wMonth = exploded.month; | 231 st.wMonth = static_cast<WORD>(exploded.month); |
232 st.wDayOfWeek = exploded.day_of_week; | 232 st.wDayOfWeek = static_cast<WORD>(exploded.day_of_week); |
233 st.wDay = exploded.day_of_month; | 233 st.wDay = static_cast<WORD>(exploded.day_of_month); |
234 st.wHour = exploded.hour; | 234 st.wHour = static_cast<WORD>(exploded.hour); |
235 st.wMinute = exploded.minute; | 235 st.wMinute = static_cast<WORD>(exploded.minute); |
236 st.wSecond = exploded.second; | 236 st.wSecond = static_cast<WORD>(exploded.second); |
237 st.wMilliseconds = exploded.millisecond; | 237 st.wMilliseconds = static_cast<WORD>(exploded.millisecond); |
238 | 238 |
239 FILETIME ft; | 239 FILETIME ft; |
240 bool success = true; | 240 bool success = true; |
241 // Ensure that it's in UTC. | 241 // Ensure that it's in UTC. |
242 if (is_local) { | 242 if (is_local) { |
243 SYSTEMTIME utc_st; | 243 SYSTEMTIME utc_st; |
244 success = TzSpecificLocalTimeToSystemTime(NULL, &st, &utc_st) && | 244 success = TzSpecificLocalTimeToSystemTime(NULL, &st, &utc_st) && |
245 SystemTimeToFileTime(&utc_st, &ft); | 245 SystemTimeToFileTime(&utc_st, &ft); |
246 } else { | 246 } else { |
247 success = !!SystemTimeToFileTime(&st, &ft); | 247 success = !!SystemTimeToFileTime(&st, &ft); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime()); | 547 return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime()); |
548 } | 548 } |
549 } | 549 } |
550 | 550 |
551 // TimeDelta ------------------------------------------------------------------ | 551 // TimeDelta ------------------------------------------------------------------ |
552 | 552 |
553 // static | 553 // static |
554 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 554 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
555 return TimeDelta(GetHighResNowSingleton()->QPCValueToMicroseconds(qpc_value)); | 555 return TimeDelta(GetHighResNowSingleton()->QPCValueToMicroseconds(qpc_value)); |
556 } | 556 } |
OLD | NEW |