OLD | NEW |
1 // Copyright (c) 2009 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 |
11 // microseconds. | 11 // microseconds. |
12 // | 12 // |
13 // TimeTicks represents an abstract time that is always incrementing for use | 13 // TimeTicks represents an abstract time that is always incrementing for use |
14 // in measuring time durations. It is internally represented in microseconds. | 14 // in measuring time durations. It is internally represented in microseconds. |
15 // It can not be converted to a human-readable time, but is guaranteed not to | 15 // It can not be converted to a human-readable time, but is guaranteed not to |
16 // decrease (if the user changes the computer clock, Time::Now() may actually | 16 // decrease (if the user changes the computer clock, Time::Now() may actually |
17 // decrease or jump). | 17 // decrease or jump). |
18 // | 18 // |
19 // These classes are represented as only a 64-bit value, so they can be | 19 // These classes are represented as only a 64-bit value, so they can be |
20 // efficiently passed by value. | 20 // efficiently passed by value. |
21 | 21 |
22 #ifndef BASE_TIME_H_ | 22 #ifndef BASE_TIME_H_ |
23 #define BASE_TIME_H_ | 23 #define BASE_TIME_H_ |
24 | 24 |
25 #include <time.h> | 25 #include <time.h> |
26 | 26 |
27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
28 | 28 |
| 29 #if defined(OS_POSIX) |
| 30 // For struct timeval. |
| 31 #include <sys/time.h> |
| 32 #endif |
| 33 |
29 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
30 // For FILETIME in FromFileTime, until it moves to a new converter class. | 35 // For FILETIME in FromFileTime, until it moves to a new converter class. |
31 // See TODO(iyengar) below. | 36 // See TODO(iyengar) below. |
32 #include <windows.h> | 37 #include <windows.h> |
33 #endif | 38 #endif |
34 | 39 |
35 namespace base { | 40 namespace base { |
36 | 41 |
37 class Time; | 42 class Time; |
38 class TimeTicks; | 43 class TimeTicks; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // TODO(brettw) this should be removed once everybody starts using the |Time| | 239 // TODO(brettw) this should be removed once everybody starts using the |Time| |
235 // class. | 240 // class. |
236 static Time FromTimeT(time_t tt); | 241 static Time FromTimeT(time_t tt); |
237 time_t ToTimeT() const; | 242 time_t ToTimeT() const; |
238 | 243 |
239 // Converts time to/from a double which is the number of seconds since epoch | 244 // Converts time to/from a double which is the number of seconds since epoch |
240 // (Jan 1, 1970). Webkit uses this format to represent time. | 245 // (Jan 1, 1970). Webkit uses this format to represent time. |
241 static Time FromDoubleT(double dt); | 246 static Time FromDoubleT(double dt); |
242 double ToDoubleT() const; | 247 double ToDoubleT() const; |
243 | 248 |
| 249 #if defined(OS_POSIX) |
| 250 struct timeval ToTimeVal() const; |
| 251 #endif |
244 | 252 |
245 #if defined(OS_WIN) | 253 #if defined(OS_WIN) |
246 static Time FromFileTime(FILETIME ft); | 254 static Time FromFileTime(FILETIME ft); |
247 FILETIME ToFileTime() const; | 255 FILETIME ToFileTime() const; |
248 | 256 |
249 // Enable or disable Windows high resolution timer. For more details | 257 // Enable or disable Windows high resolution timer. For more details |
250 // see comments in time_win.cc. Returns true on success. | 258 // see comments in time_win.cc. Returns true on success. |
251 static bool UseHighResolutionTimer(bool use); | 259 static bool UseHighResolutionTimer(bool use); |
252 #endif | 260 #endif |
253 | 261 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 #endif | 504 #endif |
497 }; | 505 }; |
498 | 506 |
499 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 507 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
500 return TimeTicks(t.ticks_ + delta_); | 508 return TimeTicks(t.ticks_ + delta_); |
501 } | 509 } |
502 | 510 |
503 } // namespace base | 511 } // namespace base |
504 | 512 |
505 #endif // BASE_TIME_H_ | 513 #endif // BASE_TIME_H_ |
OLD | NEW |