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

Side by Side Diff: base/time_win.cc

Issue 552004: Style cleanup in preparation for auto-linting base/. (Closed)
Patch Set: Created 10 years, 11 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
« no previous file with comments | « base/thread_local_storage.h ('k') | base/timer.h » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // We implement time using the high-resolution timers so that we can get 106 // We implement time using the high-resolution timers so that we can get
107 // timeouts which are smaller than 10-15ms. If we just used 107 // timeouts which are smaller than 10-15ms. If we just used
108 // CurrentWallclockMicroseconds(), we'd have the less-granular timer. 108 // CurrentWallclockMicroseconds(), we'd have the less-granular timer.
109 // 109 //
110 // To make this work, we initialize the clock (initial_time) and the 110 // To make this work, we initialize the clock (initial_time) and the
111 // counter (initial_ctr). To compute the initial time, we can check 111 // counter (initial_ctr). To compute the initial time, we can check
112 // the number of ticks that have elapsed, and compute the delta. 112 // the number of ticks that have elapsed, and compute the delta.
113 // 113 //
114 // To avoid any drift, we periodically resync the counters to the system 114 // To avoid any drift, we periodically resync the counters to the system
115 // clock. 115 // clock.
116 while(true) { 116 while (true) {
117 TimeTicks ticks = TimeTicks::Now(); 117 TimeTicks ticks = TimeTicks::Now();
118 118
119 // Calculate the time elapsed since we started our timer 119 // Calculate the time elapsed since we started our timer
120 TimeDelta elapsed = ticks - initial_ticks; 120 TimeDelta elapsed = ticks - initial_ticks;
121 121
122 // Check if enough time has elapsed that we need to resync the clock. 122 // Check if enough time has elapsed that we need to resync the clock.
123 if (elapsed.InMilliseconds() > kMaxMillisecondsToAvoidDrift) { 123 if (elapsed.InMilliseconds() > kMaxMillisecondsToAvoidDrift) {
124 InitializeClock(); 124 InitializeClock();
125 continue; 125 continue;
126 } 126 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 // static 382 // static
383 TimeTicks TimeTicks::Now() { 383 TimeTicks TimeTicks::Now() {
384 return TimeTicks() + Singleton<NowSingleton>::get()->Now(); 384 return TimeTicks() + Singleton<NowSingleton>::get()->Now();
385 } 385 }
386 386
387 // static 387 // static
388 TimeTicks TimeTicks::HighResNow() { 388 TimeTicks TimeTicks::HighResNow() {
389 return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now(); 389 return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now();
390 } 390 }
OLDNEW
« no previous file with comments | « base/thread_local_storage.h ('k') | base/timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698