OLD | NEW |
1 // Copyright (c) 2010 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 |
11 // microseconds. | 11 // microseconds. |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 bool operator>(Time other) const { | 378 bool operator>(Time other) const { |
379 return us_ > other.us_; | 379 return us_ > other.us_; |
380 } | 380 } |
381 bool operator>=(Time other) const { | 381 bool operator>=(Time other) const { |
382 return us_ >= other.us_; | 382 return us_ >= other.us_; |
383 } | 383 } |
384 | 384 |
385 private: | 385 private: |
386 friend class TimeDelta; | 386 friend class TimeDelta; |
387 | 387 |
| 388 explicit Time(int64 us) : us_(us) { |
| 389 } |
| 390 |
388 // Explodes the given time to either local time |is_local = true| or UTC | 391 // Explodes the given time to either local time |is_local = true| or UTC |
389 // |is_local = false|. | 392 // |is_local = false|. |
390 void Explode(bool is_local, Exploded* exploded) const; | 393 void Explode(bool is_local, Exploded* exploded) const; |
391 | 394 |
392 // Unexplodes a given time assuming the source is either local time | 395 // Unexplodes a given time assuming the source is either local time |
393 // |is_local = true| or UTC |is_local = false|. | 396 // |is_local = true| or UTC |is_local = false|. |
394 static Time FromExploded(bool is_local, const Exploded& exploded); | 397 static Time FromExploded(bool is_local, const Exploded& exploded); |
395 | 398 |
396 explicit Time(int64 us) : us_(us) { | |
397 } | |
398 | |
399 // The representation of Jan 1, 1970 UTC in microseconds since the | 399 // The representation of Jan 1, 1970 UTC in microseconds since the |
400 // platform-dependent epoch. | 400 // platform-dependent epoch. |
401 static const int64 kTimeTToMicrosecondsOffset; | 401 static const int64 kTimeTToMicrosecondsOffset; |
402 | 402 |
403 #if defined(OS_WIN) | 403 #if defined(OS_WIN) |
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 |
(...skipping 141 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 |