OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Time represents an absolute point in time, internally represented as | 5 // Time represents an absolute point in time, internally represented as |
6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each | 6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each |
7 // platform's epoch, along with other system-dependent clock interface | 7 // platform's epoch, along with other system-dependent clock interface |
8 // routines, is defined in time_PLATFORM.cc. | 8 // routines, is defined in time_PLATFORM.cc. |
9 // | 9 // |
10 // TimeDelta represents a duration of time, internally represented in | 10 // TimeDelta represents a duration of time, internally represented in |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 // When disabling the high resolution timer, this function will not cause | 276 // When disabling the high resolution timer, this function will not cause |
277 // the high resolution timer to be deactivated, but will prevent future | 277 // the high resolution timer to be deactivated, but will prevent future |
278 // activations. | 278 // activations. |
279 // Must be called from the main thread. | 279 // Must be called from the main thread. |
280 // For more details see comments in time_win.cc. | 280 // For more details see comments in time_win.cc. |
281 static void EnableHighResolutionTimer(bool enable); | 281 static void EnableHighResolutionTimer(bool enable); |
282 | 282 |
283 // Activates or deactivates the high resolution timer based on the |activate| | 283 // Activates or deactivates the high resolution timer based on the |activate| |
284 // flag. If the HighResolutionTimer is not Enabled (see | 284 // flag. If the HighResolutionTimer is not Enabled (see |
285 // EnableHighResolutionTimer), this function will return false. Otherwise | 285 // EnableHighResolutionTimer), this function will return false. Otherwise |
286 // returns true. | 286 // returns true. Each successful activate call must be paired with a |
287 // subsequent deactivate call. | |
287 // All callers to activate the high resolution timer must eventually call | 288 // All callers to activate the high resolution timer must eventually call |
288 // this function to deactivate the high resolution timer. | 289 // this function to deactivate the high resolution timer. |
289 static bool ActivateHighResolutionTimer(bool activate); | 290 static bool ActivateHighResolutionTimer(bool activate); |
291 | |
292 // Returns true if the high resolution timer is both enabled and activated. | |
293 // This is provided for testing only, and is not tracked in a thread-safe | |
294 // way. | |
295 static bool IsHighResolutionTimerInUse(); | |
290 #endif | 296 #endif |
291 | 297 |
292 // Converts an exploded structure representing either the local time or UTC | 298 // Converts an exploded structure representing either the local time or UTC |
293 // into a Time class. | 299 // into a Time class. |
294 static Time FromUTCExploded(const Exploded& exploded) { | 300 static Time FromUTCExploded(const Exploded& exploded) { |
295 return FromExploded(false, exploded); | 301 return FromExploded(false, exploded); |
296 } | 302 } |
297 static Time FromLocalExploded(const Exploded& exploded) { | 303 static Time FromLocalExploded(const Exploded& exploded) { |
298 return FromExploded(true, exploded); | 304 return FromExploded(true, exploded); |
299 } | 305 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 | 404 |
399 // The representation of Jan 1, 1970 UTC in microseconds since the | 405 // The representation of Jan 1, 1970 UTC in microseconds since the |
400 // platform-dependent epoch. | 406 // platform-dependent epoch. |
401 static const int64 kTimeTToMicrosecondsOffset; | 407 static const int64 kTimeTToMicrosecondsOffset; |
402 | 408 |
403 #if defined(OS_WIN) | 409 #if defined(OS_WIN) |
404 // Indicates whether fast timers are usable right now. For instance, | 410 // Indicates whether fast timers are usable right now. For instance, |
405 // when using battery power, we might elect to prevent high speed timers | 411 // when using battery power, we might elect to prevent high speed timers |
406 // which would draw more power. | 412 // which would draw more power. |
407 static bool high_resolution_timer_enabled_; | 413 static bool high_resolution_timer_enabled_; |
414 // Count of activations on the high resolution timer. Not tracked | |
415 // in a thread safe way. | |
jar (doing other things)
2010/10/20 00:37:19
Please add to comment:
...and used ONLY by tests w
| |
416 static int high_resolution_timer_activated_; | |
408 #endif | 417 #endif |
409 | 418 |
410 // Time in microseconds in UTC. | 419 // Time in microseconds in UTC. |
411 int64 us_; | 420 int64 us_; |
412 }; | 421 }; |
413 | 422 |
414 inline Time TimeDelta::operator+(Time t) const { | 423 inline Time TimeDelta::operator+(Time t) const { |
415 return Time(t.us_ + delta_); | 424 return Time(t.us_ + delta_); |
416 } | 425 } |
417 | 426 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 #endif | 559 #endif |
551 }; | 560 }; |
552 | 561 |
553 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 562 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
554 return TimeTicks(t.ticks_ + delta_); | 563 return TimeTicks(t.ticks_ + delta_); |
555 } | 564 } |
556 | 565 |
557 } // namespace base | 566 } // namespace base |
558 | 567 |
559 #endif // BASE_TIME_H_ | 568 #endif // BASE_TIME_H_ |
OLD | NEW |