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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 time_t ToTimeT() const; | 259 time_t ToTimeT() const; |
260 | 260 |
261 // Converts time to/from a double which is the number of seconds since epoch | 261 // Converts time to/from a double which is the number of seconds since epoch |
262 // (Jan 1, 1970). Webkit uses this format to represent time. | 262 // (Jan 1, 1970). Webkit uses this format to represent time. |
263 // Because WebKit initializes double time value to 0 to indicate "not | 263 // Because WebKit initializes double time value to 0 to indicate "not |
264 // initialized", we map it to empty Time object that also means "not | 264 // initialized", we map it to empty Time object that also means "not |
265 // initialized". | 265 // initialized". |
266 static Time FromDoubleT(double dt); | 266 static Time FromDoubleT(double dt); |
267 double ToDoubleT() const; | 267 double ToDoubleT() const; |
268 | 268 |
| 269 // Converts to/from the Javascript convention for times, a number of |
| 270 // milliseconds since the epoch: |
| 271 // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/g
etTime. |
| 272 static Time FromJsTime(double ms_since_epoch); |
| 273 double ToJsTime() const; |
| 274 |
269 #if defined(OS_POSIX) | 275 #if defined(OS_POSIX) |
270 struct timeval ToTimeVal() const; | 276 struct timeval ToTimeVal() const; |
271 #endif | 277 #endif |
272 | 278 |
273 #if defined(OS_WIN) | 279 #if defined(OS_WIN) |
274 static Time FromFileTime(FILETIME ft); | 280 static Time FromFileTime(FILETIME ft); |
275 FILETIME ToFileTime() const; | 281 FILETIME ToFileTime() const; |
276 | 282 |
277 // The minimum time of a low resolution timer. This is basically a windows | 283 // The minimum time of a low resolution timer. This is basically a windows |
278 // constant of ~15.6ms. While it does vary on some older OS versions, we'll | 284 // constant of ~15.6ms. While it does vary on some older OS versions, we'll |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 #endif | 588 #endif |
583 }; | 589 }; |
584 | 590 |
585 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 591 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
586 return TimeTicks(t.ticks_ + delta_); | 592 return TimeTicks(t.ticks_ + delta_); |
587 } | 593 } |
588 | 594 |
589 } // namespace base | 595 } // namespace base |
590 | 596 |
591 #endif // BASE_TIME_H_ | 597 #endif // BASE_TIME_H_ |
OLD | NEW |