| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // Indicates whether fast timers are usable right now. For instance, | 404 // Indicates whether fast timers are usable right now. For instance, |
| 405 // when using battery power, we might elect to prevent high speed timers | 405 // when using battery power, we might elect to prevent high speed timers |
| 406 // which would draw more power. | 406 // which would draw more power. |
| 407 static bool high_resolution_timer_enabled_; | 407 static bool high_resolution_timer_enabled_; |
| 408 #endif | 408 #endif |
| 409 | 409 |
| 410 // Time in microseconds in UTC. | 410 // Time in microseconds in UTC. |
| 411 int64 us_; | 411 int64 us_; |
| 412 }; | 412 }; |
| 413 | 413 |
| 414 inline Time TimeDelta::operator+(Time t) const { | |
| 415 return Time(t.us_ + delta_); | |
| 416 } | |
| 417 | |
| 418 // Inline the TimeDelta factory methods, for fast TimeDelta construction. | 414 // Inline the TimeDelta factory methods, for fast TimeDelta construction. |
| 419 | 415 |
| 420 // static | 416 // static |
| 421 inline TimeDelta TimeDelta::FromDays(int64 days) { | 417 inline TimeDelta TimeDelta::FromDays(int64 days) { |
| 422 return TimeDelta(days * Time::kMicrosecondsPerDay); | 418 return TimeDelta(days * Time::kMicrosecondsPerDay); |
| 423 } | 419 } |
| 424 | 420 |
| 425 // static | 421 // static |
| 426 inline TimeDelta TimeDelta::FromHours(int64 hours) { | 422 inline TimeDelta TimeDelta::FromHours(int64 hours) { |
| 427 return TimeDelta(hours * Time::kMicrosecondsPerHour); | 423 return TimeDelta(hours * Time::kMicrosecondsPerHour); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 440 // static | 436 // static |
| 441 inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) { | 437 inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) { |
| 442 return TimeDelta(ms * Time::kMicrosecondsPerMillisecond); | 438 return TimeDelta(ms * Time::kMicrosecondsPerMillisecond); |
| 443 } | 439 } |
| 444 | 440 |
| 445 // static | 441 // static |
| 446 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) { | 442 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) { |
| 447 return TimeDelta(us); | 443 return TimeDelta(us); |
| 448 } | 444 } |
| 449 | 445 |
| 446 inline Time TimeDelta::operator+(Time t) const { |
| 447 return Time(t.us_ + delta_); |
| 448 } |
| 449 |
| 450 // TimeTicks ------------------------------------------------------------------ | 450 // TimeTicks ------------------------------------------------------------------ |
| 451 | 451 |
| 452 class TimeTicks { | 452 class TimeTicks { |
| 453 public: | 453 public: |
| 454 TimeTicks() : ticks_(0) { | 454 TimeTicks() : ticks_(0) { |
| 455 } | 455 } |
| 456 | 456 |
| 457 // Platform-dependent tick count representing "right now." | 457 // Platform-dependent tick count representing "right now." |
| 458 // The resolution of this clock is ~1-15ms. Resolution varies depending | 458 // The resolution of this clock is ~1-15ms. Resolution varies depending |
| 459 // on hardware/operating system configuration. | 459 // on hardware/operating system configuration. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 #endif | 550 #endif |
| 551 }; | 551 }; |
| 552 | 552 |
| 553 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 553 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
| 554 return TimeTicks(t.ticks_ + delta_); | 554 return TimeTicks(t.ticks_ + delta_); |
| 555 } | 555 } |
| 556 | 556 |
| 557 } // namespace base | 557 } // namespace base |
| 558 | 558 |
| 559 #endif // BASE_TIME_H_ | 559 #endif // BASE_TIME_H_ |
| OLD | NEW |