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

Side by Side Diff: base/time_win.cc

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Mock TimeTicks::Now() Created 8 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding 96 // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding
97 // 1700, 1800, and 1900. 97 // 1700, 1800, and 1900.
98 // static 98 // static
99 const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(11644473600000000); 99 const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(11644473600000000);
100 100
101 bool Time::high_resolution_timer_enabled_ = false; 101 bool Time::high_resolution_timer_enabled_ = false;
102 int Time::high_resolution_timer_activated_ = 0; 102 int Time::high_resolution_timer_activated_ = 0;
103 103
104 // static 104 // static
105 Time Time::Now() { 105 Time Time::Now() {
106 if (TimeFactory::instance())
107 return TimeFactory::instance()->TimeNow();
108
106 if (initial_time == 0) 109 if (initial_time == 0)
107 InitializeClock(); 110 InitializeClock();
108 111
109 // We implement time using the high-resolution timers so that we can get 112 // We implement time using the high-resolution timers so that we can get
110 // timeouts which are smaller than 10-15ms. If we just used 113 // timeouts which are smaller than 10-15ms. If we just used
111 // CurrentWallclockMicroseconds(), we'd have the less-granular timer. 114 // CurrentWallclockMicroseconds(), we'd have the less-granular timer.
112 // 115 //
113 // To make this work, we initialize the clock (initial_time) and the 116 // To make this work, we initialize the clock (initial_time) and the
114 // counter (initial_ctr). To compute the initial time, we can check 117 // counter (initial_ctr). To compute the initial time, we can check
115 // the number of ticks that have elapsed, and compute the delta. 118 // the number of ticks that have elapsed, and compute the delta.
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // static 447 // static
445 TimeTicks::TickFunctionType TimeTicks::SetMockTickFunction( 448 TimeTicks::TickFunctionType TimeTicks::SetMockTickFunction(
446 TickFunctionType ticker) { 449 TickFunctionType ticker) {
447 TickFunctionType old = tick_function; 450 TickFunctionType old = tick_function;
448 tick_function = ticker; 451 tick_function = ticker;
449 return old; 452 return old;
450 } 453 }
451 454
452 // static 455 // static
453 TimeTicks TimeTicks::Now() { 456 TimeTicks TimeTicks::Now() {
457 if (TimeFactory::instance())
458 return TimeFactory::instance()->TimeTicksNow();
459
454 return TimeTicks() + RolloverProtectedNow(); 460 return TimeTicks() + RolloverProtectedNow();
455 } 461 }
456 462
457 // static 463 // static
458 TimeTicks TimeTicks::HighResNow() { 464 TimeTicks TimeTicks::HighResNow() {
465 if (TimeFactory::instance())
466 return TimeFactory::instance()->TimeTicksHighResNow();
467
459 return TimeTicks() + HighResNowSingleton::GetInstance()->Now(); 468 return TimeTicks() + HighResNowSingleton::GetInstance()->Now();
460 } 469 }
461 470
462 // static 471 // static
463 TimeTicks TimeTicks::NowFromSystemTraceTime() { 472 TimeTicks TimeTicks::NowFromSystemTraceTime() {
464 return HighResNow(); 473 return HighResNow();
465 } 474 }
466 475
467 // static 476 // static
468 int64 TimeTicks::GetQPCDriftMicroseconds() { 477 int64 TimeTicks::GetQPCDriftMicroseconds() {
(...skipping 11 matching lines...) Expand all
480 return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); 489 return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
481 } 490 }
482 491
483 // TimeDelta ------------------------------------------------------------------ 492 // TimeDelta ------------------------------------------------------------------
484 493
485 // static 494 // static
486 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { 495 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) {
487 return TimeDelta( 496 return TimeDelta(
488 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value)); 497 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value));
489 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698