license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 4 | |
| 5 | // Time represents an absolute point in time, internally represented as |
| 6 | // microseconds (s/1,000,000) since a platform-dependent epoch. Each |
| 7 | // platform's epoch, along with other system-dependent clock interface |
| 8 | // routines, is defined in time_PLATFORM.cc. |
| 9 | // |
| 10 | // TimeDelta represents a duration of time, internally represented in |
| 11 | // microseconds. |
| 12 | // |
| 13 | // TimeTicks represents an abstract time that is always incrementing for use |
| 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 |
| 16 | // decrease (if the user changes the computer clock, Time::Now() may actually |
| 17 | // decrease or jump). |
| 18 | // |
| 19 | // These classes are represented as only a 64-bit value, so they can be |
| 20 | // efficiently passed by value. |
| 21 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 22 | #ifndef BASE_TIME_H_ |
| 23 | #define BASE_TIME_H_ |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 24 | |
| 25 | #include <time.h> |
mmentovai@google.com | 7ba78d7 | 2008-08-12 03:15:10 +0900 | [diff] [blame] | 26 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 27 | #include "base/basictypes.h" |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 28 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 29 | #if defined(OS_WIN) |
| 30 | // For FILETIME in FromFileTime, until it moves to a new converter class. |
| 31 | // See TODO(iyengar) below. |
| 32 | #include <windows.h> |
| 33 | #endif |
| 34 | |
dsh@google.com | 0f8dd26 | 2008-10-28 05:43:33 +0900 | [diff] [blame] | 35 | namespace base { |
| 36 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 37 | class Time; |
| 38 | class TimeTicks; |
| 39 | |
| 40 | // This unit test does a lot of manual time manipulation. |
| 41 | class PageLoadTrackerUnitTest; |
| 42 | |
| 43 | // TimeDelta ------------------------------------------------------------------ |
| 44 | |
| 45 | class TimeDelta { |
| 46 | public: |
| 47 | TimeDelta() : delta_(0) { |
| 48 | } |
| 49 | |
| 50 | // Converts units of time to TimeDeltas. |
| 51 | static TimeDelta FromDays(int64 days); |
| 52 | static TimeDelta FromHours(int64 hours); |
| 53 | static TimeDelta FromMinutes(int64 minutes); |
| 54 | static TimeDelta FromSeconds(int64 secs); |
| 55 | static TimeDelta FromMilliseconds(int64 ms); |
| 56 | static TimeDelta FromMicroseconds(int64 us); |
| 57 | |
| 58 | // Returns the internal numeric value of the TimeDelta object. Please don't |
| 59 | // use this and do arithmetic on it, as it is more error prone than using the |
| 60 | // provided operators. |
| 61 | int64 ToInternalValue() const { |
| 62 | return delta_; |
| 63 | } |
| 64 | |
| 65 | // Returns the time delta in some unit. The F versions return a floating |
| 66 | // point value, the "regular" versions return a rounded-down value. |
| 67 | int InDays() const; |
| 68 | int InHours() const; |
deanm@google.com | 0278122 | 2008-08-19 18:16:49 +0900 | [diff] [blame] | 69 | int InMinutes() const; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 70 | double InSecondsF() const; |
| 71 | int64 InSeconds() const; |
| 72 | double InMillisecondsF() const; |
| 73 | int64 InMilliseconds() const; |
| 74 | int64 InMicroseconds() const; |
| 75 | |
| 76 | TimeDelta& operator=(TimeDelta other) { |
| 77 | delta_ = other.delta_; |
| 78 | return *this; |
| 79 | } |
| 80 | |
| 81 | // Computations with other deltas. |
| 82 | TimeDelta operator+(TimeDelta other) const { |
| 83 | return TimeDelta(delta_ + other.delta_); |
| 84 | } |
| 85 | TimeDelta operator-(TimeDelta other) const { |
| 86 | return TimeDelta(delta_ - other.delta_); |
| 87 | } |
| 88 | |
| 89 | TimeDelta& operator+=(TimeDelta other) { |
| 90 | delta_ += other.delta_; |
| 91 | return *this; |
| 92 | } |
| 93 | TimeDelta& operator-=(TimeDelta other) { |
| 94 | delta_ -= other.delta_; |
| 95 | return *this; |
| 96 | } |
| 97 | TimeDelta operator-() const { |
| 98 | return TimeDelta(-delta_); |
| 99 | } |
| 100 | |
| 101 | // Computations with ints, note that we only allow multiplicative operations |
| 102 | // with ints, and additive operations with other deltas. |
| 103 | TimeDelta operator*(int64 a) const { |
| 104 | return TimeDelta(delta_ * a); |
| 105 | } |
| 106 | TimeDelta operator/(int64 a) const { |
| 107 | return TimeDelta(delta_ / a); |
| 108 | } |
| 109 | TimeDelta& operator*=(int64 a) { |
| 110 | delta_ *= a; |
| 111 | return *this; |
| 112 | } |
| 113 | TimeDelta& operator/=(int64 a) { |
| 114 | delta_ /= a; |
| 115 | return *this; |
| 116 | } |
| 117 | int64 operator/(TimeDelta a) const { |
| 118 | return delta_ / a.delta_; |
| 119 | } |
| 120 | |
| 121 | // Defined below because it depends on the definition of the other classes. |
| 122 | Time operator+(Time t) const; |
| 123 | TimeTicks operator+(TimeTicks t) const; |
| 124 | |
| 125 | // Comparison operators. |
| 126 | bool operator==(TimeDelta other) const { |
| 127 | return delta_ == other.delta_; |
| 128 | } |
| 129 | bool operator!=(TimeDelta other) const { |
| 130 | return delta_ != other.delta_; |
| 131 | } |
| 132 | bool operator<(TimeDelta other) const { |
| 133 | return delta_ < other.delta_; |
| 134 | } |
| 135 | bool operator<=(TimeDelta other) const { |
| 136 | return delta_ <= other.delta_; |
| 137 | } |
| 138 | bool operator>(TimeDelta other) const { |
| 139 | return delta_ > other.delta_; |
| 140 | } |
| 141 | bool operator>=(TimeDelta other) const { |
| 142 | return delta_ >= other.delta_; |
| 143 | } |
| 144 | |
| 145 | private: |
| 146 | friend class Time; |
| 147 | friend class TimeTicks; |
| 148 | friend TimeDelta operator*(int64 a, TimeDelta td); |
| 149 | |
| 150 | // Constructs a delta given the duration in microseconds. This is private |
| 151 | // to avoid confusion by callers with an integer constructor. Use |
| 152 | // FromSeconds, FromMilliseconds, etc. instead. |
| 153 | explicit TimeDelta(int64 delta_us) : delta_(delta_us) { |
| 154 | } |
| 155 | |
| 156 | // Delta in microseconds. |
| 157 | int64 delta_; |
| 158 | }; |
| 159 | |
| 160 | inline TimeDelta operator*(int64 a, TimeDelta td) { |
| 161 | return TimeDelta(a * td.delta_); |
| 162 | } |
| 163 | |
| 164 | // Time ----------------------------------------------------------------------- |
| 165 | |
| 166 | // Represents a wall clock time. |
| 167 | class Time { |
| 168 | public: |
| 169 | static const int64 kMillisecondsPerSecond = 1000; |
| 170 | static const int64 kMicrosecondsPerMillisecond = 1000; |
| 171 | static const int64 kMicrosecondsPerSecond = kMicrosecondsPerMillisecond * |
| 172 | kMillisecondsPerSecond; |
| 173 | static const int64 kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60; |
| 174 | static const int64 kMicrosecondsPerHour = kMicrosecondsPerMinute * 60; |
| 175 | static const int64 kMicrosecondsPerDay = kMicrosecondsPerHour * 24; |
| 176 | static const int64 kMicrosecondsPerWeek = kMicrosecondsPerDay * 7; |
mmentovai@google.com | 7ba78d7 | 2008-08-12 03:15:10 +0900 | [diff] [blame] | 177 | static const int64 kNanosecondsPerMicrosecond = 1000; |
| 178 | static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond * |
| 179 | kMicrosecondsPerSecond; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 180 | |
| 181 | // Represents an exploded time that can be formatted nicely. This is kind of |
| 182 | // like the Win32 SYSTEMTIME structure or the Unix "struct tm" with a few |
| 183 | // additions and changes to prevent errors. |
| 184 | struct Exploded { |
| 185 | int year; // Four digit year "2007" |
| 186 | int month; // 1-based month (values 1 = January, etc.) |
| 187 | int day_of_week; // 0-based day of week (0 = Sunday, etc.) |
| 188 | int day_of_month; // 1-based day of month (1-31) |
| 189 | int hour; // Hour within the current day (0-23) |
| 190 | int minute; // Minute within the current hour (0-59) |
| 191 | int second; // Second within the current minute (0-59 plus leap |
| 192 | // seconds which may take it up to 60). |
| 193 | int millisecond; // Milliseconds within the current second (0-999) |
| 194 | }; |
| 195 | |
| 196 | // Contains the NULL time. Use Time::Now() to get the current time. |
| 197 | explicit Time() : us_(0) { |
| 198 | } |
| 199 | |
| 200 | // Returns true if the time object has not been initialized. |
| 201 | bool is_null() const { |
| 202 | return us_ == 0; |
| 203 | } |
| 204 | |
| 205 | // Returns the current time. Watch out, the system might adjust its clock |
| 206 | // in which case time will actually go backwards. We don't guarantee that |
| 207 | // times are increasing, or that two calls to Now() won't be the same. |
| 208 | static Time Now(); |
| 209 | |
erikkay@google.com | 9ac2676 | 2009-04-18 09:42:48 +0900 | [diff] [blame] | 210 | // Returns the current time. Same as Now() except that this function always |
| 211 | // uses system time so that there are no discrepancies between the returned |
| 212 | // time and system time even on virtual environments including our test bot. |
| 213 | // For timing sensitive unittests, this function should be used. |
| 214 | static Time NowFromSystemTime(); |
| 215 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 216 | // Converts to/from time_t in UTC and a Time class. |
| 217 | // TODO(brettw) this should be removed once everybody starts using the |Time| |
| 218 | // class. |
| 219 | static Time FromTimeT(time_t tt); |
| 220 | time_t ToTimeT() const; |
| 221 | |
davemoore@chromium.org | 60adf6e | 2009-04-04 06:39:26 +0900 | [diff] [blame] | 222 | // Converts time to/from a double which is the number of seconds since epoch |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 223 | // (Jan 1, 1970). Webkit uses this format to represent time. |
davemoore@chromium.org | 60adf6e | 2009-04-04 06:39:26 +0900 | [diff] [blame] | 224 | static Time FromDoubleT(double dt); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 225 | double ToDoubleT() const; |
| 226 | |
davemoore@chromium.org | 60adf6e | 2009-04-04 06:39:26 +0900 | [diff] [blame] | 227 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 228 | #if defined(OS_WIN) |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 229 | static Time FromFileTime(FILETIME ft); |
| 230 | FILETIME ToFileTime() const; |
phajdan.jr@chromium.org | be5fc0f | 2009-05-27 17:12:55 +0900 | [diff] [blame] | 231 | |
| 232 | // Monitor system power state and disable high resolution timer when we're |
| 233 | // on battery. See time_win.cc for more details. |
| 234 | static void StartSystemMonitorObserver(); |
| 235 | |
| 236 | // Enable high resolution timer unconditionally. Only for test code. |
| 237 | static void EnableHiResClockForTests(); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 238 | #endif |
| 239 | |
| 240 | // Converts an exploded structure representing either the local time or UTC |
| 241 | // into a Time class. |
| 242 | static Time FromUTCExploded(const Exploded& exploded) { |
| 243 | return FromExploded(false, exploded); |
| 244 | } |
| 245 | static Time FromLocalExploded(const Exploded& exploded) { |
| 246 | return FromExploded(true, exploded); |
| 247 | } |
| 248 | |
| 249 | // Converts an integer value representing Time to a class. This is used |
| 250 | // when deserializing a |Time| structure, using a value known to be |
| 251 | // compatible. It is not provided as a constructor because the integer type |
| 252 | // may be unclear from the perspective of a caller. |
| 253 | static Time FromInternalValue(int64 us) { |
| 254 | return Time(us); |
| 255 | } |
| 256 | |
| 257 | // Converts a string representation of time to a Time object. |
| 258 | // An example of a time string which is converted is as below:- |
| 259 | // "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified |
| 260 | // in the input string, we assume local time. |
| 261 | // TODO(iyengar) Move the FromString/FromTimeT/ToTimeT/FromFileTime to |
| 262 | // a new time converter class. |
| 263 | static bool FromString(const wchar_t* time_string, Time* parsed_time); |
| 264 | |
| 265 | // For serializing, use FromInternalValue to reconstitute. Please don't use |
| 266 | // this and do arithmetic on it, as it is more error prone than using the |
| 267 | // provided operators. |
| 268 | int64 ToInternalValue() const { |
| 269 | return us_; |
| 270 | } |
| 271 | |
| 272 | // Fills the given exploded structure with either the local time or UTC from |
| 273 | // this time structure (containing UTC). |
| 274 | void UTCExplode(Exploded* exploded) const { |
| 275 | return Explode(false, exploded); |
| 276 | } |
| 277 | void LocalExplode(Exploded* exploded) const { |
| 278 | return Explode(true, exploded); |
| 279 | } |
| 280 | |
| 281 | // Rounds this time down to the nearest day in local time. It will represent |
| 282 | // midnight on that day. |
| 283 | Time LocalMidnight() const; |
| 284 | |
| 285 | Time& operator=(Time other) { |
| 286 | us_ = other.us_; |
| 287 | return *this; |
| 288 | } |
| 289 | |
| 290 | // Compute the difference between two times. |
| 291 | TimeDelta operator-(Time other) const { |
| 292 | return TimeDelta(us_ - other.us_); |
| 293 | } |
| 294 | |
| 295 | // Modify by some time delta. |
| 296 | Time& operator+=(TimeDelta delta) { |
| 297 | us_ += delta.delta_; |
| 298 | return *this; |
| 299 | } |
| 300 | Time& operator-=(TimeDelta delta) { |
| 301 | us_ -= delta.delta_; |
| 302 | return *this; |
| 303 | } |
| 304 | |
| 305 | // Return a new time modified by some delta. |
| 306 | Time operator+(TimeDelta delta) const { |
| 307 | return us_ + delta.delta_; |
| 308 | } |
| 309 | Time operator-(TimeDelta delta) const { |
| 310 | return us_ - delta.delta_; |
| 311 | } |
| 312 | |
| 313 | // Comparison operators |
| 314 | bool operator==(Time other) const { |
| 315 | return us_ == other.us_; |
| 316 | } |
| 317 | bool operator!=(Time other) const { |
| 318 | return us_ != other.us_; |
| 319 | } |
| 320 | bool operator<(Time other) const { |
| 321 | return us_ < other.us_; |
| 322 | } |
| 323 | bool operator<=(Time other) const { |
| 324 | return us_ <= other.us_; |
| 325 | } |
| 326 | bool operator>(Time other) const { |
| 327 | return us_ > other.us_; |
| 328 | } |
| 329 | bool operator>=(Time other) const { |
| 330 | return us_ >= other.us_; |
| 331 | } |
| 332 | |
| 333 | private: |
| 334 | friend class TimeDelta; |
| 335 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 336 | // Explodes the given time to either local time |is_local = true| or UTC |
| 337 | // |is_local = false|. |
| 338 | void Explode(bool is_local, Exploded* exploded) const; |
| 339 | |
| 340 | // Unexplodes a given time assuming the source is either local time |
| 341 | // |is_local = true| or UTC |is_local = false|. |
| 342 | static Time FromExploded(bool is_local, const Exploded& exploded); |
| 343 | |
| 344 | Time(int64 us) : us_(us) { |
| 345 | } |
| 346 | |
| 347 | // The representation of Jan 1, 1970 UTC in microseconds since the |
| 348 | // platform-dependent epoch. |
| 349 | static const int64 kTimeTToMicrosecondsOffset; |
| 350 | |
| 351 | // Time in microseconds in UTC. |
| 352 | int64 us_; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 353 | }; |
| 354 | |
| 355 | inline Time TimeDelta::operator+(Time t) const { |
| 356 | return Time(t.us_ + delta_); |
| 357 | } |
| 358 | |
deanm@chromium.org | d08e9e6 | 2009-01-14 00:20:06 +0900 | [diff] [blame] | 359 | // Inline the TimeDelta factory methods, for fast TimeDelta construction. |
| 360 | |
| 361 | // static |
| 362 | inline TimeDelta TimeDelta::FromDays(int64 days) { |
| 363 | return TimeDelta(days * Time::kMicrosecondsPerDay); |
| 364 | } |
| 365 | |
| 366 | // static |
| 367 | inline TimeDelta TimeDelta::FromHours(int64 hours) { |
| 368 | return TimeDelta(hours * Time::kMicrosecondsPerHour); |
| 369 | } |
| 370 | |
| 371 | // static |
| 372 | inline TimeDelta TimeDelta::FromMinutes(int64 minutes) { |
| 373 | return TimeDelta(minutes * Time::kMicrosecondsPerMinute); |
| 374 | } |
| 375 | |
| 376 | // static |
| 377 | inline TimeDelta TimeDelta::FromSeconds(int64 secs) { |
| 378 | return TimeDelta(secs * Time::kMicrosecondsPerSecond); |
| 379 | } |
| 380 | |
| 381 | // static |
| 382 | inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) { |
| 383 | return TimeDelta(ms * Time::kMicrosecondsPerMillisecond); |
| 384 | } |
| 385 | |
| 386 | // static |
| 387 | inline TimeDelta TimeDelta::FromMicroseconds(int64 us) { |
| 388 | return TimeDelta(us); |
| 389 | } |
| 390 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 391 | // TimeTicks ------------------------------------------------------------------ |
| 392 | |
| 393 | class TimeTicks { |
| 394 | public: |
| 395 | TimeTicks() : ticks_(0) { |
| 396 | } |
| 397 | |
| 398 | // Platform-dependent tick count representing "right now." |
mbelshe@google.com | 556bc84 | 2008-09-26 12:00:00 +0900 | [diff] [blame] | 399 | // The resolution of this clock is ~1-15ms. Resolution varies depending |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 400 | // on hardware/operating system configuration. |
| 401 | static TimeTicks Now(); |
| 402 | |
mbelshe@google.com | 556bc84 | 2008-09-26 12:00:00 +0900 | [diff] [blame] | 403 | // Returns a platform-dependent high-resolution tick count. Implementation |
| 404 | // is hardware dependent and may or may not return sub-millisecond |
| 405 | // resolution. THIS CALL IS GENERALLY MUCH MORE EXPENSIVE THAN Now() AND |
| 406 | // SHOULD ONLY BE USED WHEN IT IS REALLY NEEDED. |
| 407 | static TimeTicks HighResNow(); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 408 | |
| 409 | // Returns true if this object has not been initialized. |
| 410 | bool is_null() const { |
| 411 | return ticks_ == 0; |
| 412 | } |
| 413 | |
avi@google.com | 6f9d682 | 2008-09-10 03:33:11 +0900 | [diff] [blame] | 414 | // Returns the internal numeric value of the TimeTicks object. |
| 415 | int64 ToInternalValue() const { |
| 416 | return ticks_; |
| 417 | } |
| 418 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 419 | TimeTicks& operator=(TimeTicks other) { |
| 420 | ticks_ = other.ticks_; |
| 421 | return *this; |
| 422 | } |
| 423 | |
| 424 | // Compute the difference between two times. |
| 425 | TimeDelta operator-(TimeTicks other) const { |
| 426 | return TimeDelta(ticks_ - other.ticks_); |
| 427 | } |
| 428 | |
| 429 | // Modify by some time delta. |
| 430 | TimeTicks& operator+=(TimeDelta delta) { |
| 431 | ticks_ += delta.delta_; |
| 432 | return *this; |
| 433 | } |
| 434 | TimeTicks& operator-=(TimeDelta delta) { |
| 435 | ticks_ -= delta.delta_; |
| 436 | return *this; |
| 437 | } |
| 438 | |
| 439 | // Return a new TimeTicks modified by some delta. |
| 440 | TimeTicks operator+(TimeDelta delta) const { |
| 441 | return TimeTicks(ticks_ + delta.delta_); |
| 442 | } |
| 443 | TimeTicks operator-(TimeDelta delta) const { |
| 444 | return TimeTicks(ticks_ - delta.delta_); |
| 445 | } |
| 446 | |
| 447 | // Comparison operators |
| 448 | bool operator==(TimeTicks other) const { |
| 449 | return ticks_ == other.ticks_; |
| 450 | } |
| 451 | bool operator!=(TimeTicks other) const { |
| 452 | return ticks_ != other.ticks_; |
| 453 | } |
| 454 | bool operator<(TimeTicks other) const { |
| 455 | return ticks_ < other.ticks_; |
| 456 | } |
| 457 | bool operator<=(TimeTicks other) const { |
| 458 | return ticks_ <= other.ticks_; |
| 459 | } |
| 460 | bool operator>(TimeTicks other) const { |
| 461 | return ticks_ > other.ticks_; |
| 462 | } |
| 463 | bool operator>=(TimeTicks other) const { |
| 464 | return ticks_ >= other.ticks_; |
| 465 | } |
| 466 | |
| 467 | protected: |
| 468 | friend class TimeDelta; |
| 469 | friend class PageLoadTrackerUnitTest; |
| 470 | |
| 471 | // Please use Now() to create a new object. This is for internal use |
| 472 | // and testing. Ticks is in microseconds. |
| 473 | explicit TimeTicks(int64 ticks) : ticks_(ticks) { |
| 474 | } |
| 475 | |
| 476 | // Tick count in microseconds. |
| 477 | int64 ticks_; |
| 478 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 479 | #if defined(OS_WIN) |
deanm@google.com | 1fdfd51 | 2008-09-09 17:58:51 +0900 | [diff] [blame] | 480 | typedef DWORD (*TickFunctionType)(void); |
| 481 | static TickFunctionType SetMockTickFunction(TickFunctionType ticker); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 482 | #endif |
| 483 | }; |
| 484 | |
| 485 | inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
| 486 | return TimeTicks(t.ticks_ + delta_); |
| 487 | } |
| 488 | |
dsh@google.com | 0f8dd26 | 2008-10-28 05:43:33 +0900 | [diff] [blame] | 489 | } // namespace base |
| 490 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 491 | #endif // BASE_TIME_H_ |