| OLD | NEW |
| 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 // 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 27 matching lines...) Expand all Loading... |
| 38 // For struct timeval. | 38 // For struct timeval. |
| 39 #include <sys/time.h> | 39 #include <sys/time.h> |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 // For FILETIME in FromFileTime, until it moves to a new converter class. | 43 // For FILETIME in FromFileTime, until it moves to a new converter class. |
| 44 // See TODO(iyengar) below. | 44 // See TODO(iyengar) below. |
| 45 #include <windows.h> | 45 #include <windows.h> |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #include <limits> |
| 49 |
| 48 namespace base { | 50 namespace base { |
| 49 | 51 |
| 50 class Time; | 52 class Time; |
| 51 class TimeTicks; | 53 class TimeTicks; |
| 52 | 54 |
| 53 // TimeDelta ------------------------------------------------------------------ | 55 // TimeDelta ------------------------------------------------------------------ |
| 54 | 56 |
| 55 class BASE_EXPORT TimeDelta { | 57 class BASE_EXPORT TimeDelta { |
| 56 public: | 58 public: |
| 57 TimeDelta() : delta_(0) { | 59 TimeDelta() : delta_(0) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 241 |
| 240 // Contains the NULL time. Use Time::Now() to get the current time. | 242 // Contains the NULL time. Use Time::Now() to get the current time. |
| 241 explicit Time() : us_(0) { | 243 explicit Time() : us_(0) { |
| 242 } | 244 } |
| 243 | 245 |
| 244 // Returns true if the time object has not been initialized. | 246 // Returns true if the time object has not been initialized. |
| 245 bool is_null() const { | 247 bool is_null() const { |
| 246 return us_ == 0; | 248 return us_ == 0; |
| 247 } | 249 } |
| 248 | 250 |
| 251 // Returns true if the time object is the maximum time. |
| 252 bool is_max() const { |
| 253 return us_ == std::numeric_limits<int64>::max(); |
| 254 } |
| 255 |
| 249 // Returns the time for epoch in Unix-like system (Jan 1, 1970). | 256 // Returns the time for epoch in Unix-like system (Jan 1, 1970). |
| 250 static Time UnixEpoch(); | 257 static Time UnixEpoch(); |
| 251 | 258 |
| 252 // Returns the current time. Watch out, the system might adjust its clock | 259 // Returns the current time. Watch out, the system might adjust its clock |
| 253 // in which case time will actually go backwards. We don't guarantee that | 260 // in which case time will actually go backwards. We don't guarantee that |
| 254 // times are increasing, or that two calls to Now() won't be the same. | 261 // times are increasing, or that two calls to Now() won't be the same. |
| 255 static Time Now(); | 262 static Time Now(); |
| 256 | 263 |
| 257 // Returns the maximum time, which should be greater than any reasonable time | 264 // Returns the maximum time, which should be greater than any reasonable time |
| 258 // with which we might compare it. | 265 // with which we might compare it. |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 #endif | 615 #endif |
| 609 }; | 616 }; |
| 610 | 617 |
| 611 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 618 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
| 612 return TimeTicks(t.ticks_ + delta_); | 619 return TimeTicks(t.ticks_ + delta_); |
| 613 } | 620 } |
| 614 | 621 |
| 615 } // namespace base | 622 } // namespace base |
| 616 | 623 |
| 617 #endif // BASE_TIME_H_ | 624 #endif // BASE_TIME_H_ |
| OLD | NEW |