| 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 #include "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #if defined(OS_ANDROID) && !defined(__LP64__) | 10 #if defined(OS_ANDROID) && !defined(__LP64__) |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 kWindowsEpochDeltaMicroseconds); | 305 kWindowsEpochDeltaMicroseconds); |
| 306 } | 306 } |
| 307 | 307 |
| 308 // TimeTicks ------------------------------------------------------------------ | 308 // TimeTicks ------------------------------------------------------------------ |
| 309 // static | 309 // static |
| 310 TimeTicks TimeTicks::Now() { | 310 TimeTicks TimeTicks::Now() { |
| 311 return TimeTicks(ClockNow(CLOCK_MONOTONIC)); | 311 return TimeTicks(ClockNow(CLOCK_MONOTONIC)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // static | 314 // static |
| 315 TimeTicks::Clock TimeTicks::GetClock() { |
| 316 return Clock::LINUX_CLOCK_MONOTONIC; |
| 317 } |
| 318 |
| 319 // static |
| 315 bool TimeTicks::IsHighResolution() { | 320 bool TimeTicks::IsHighResolution() { |
| 316 return true; | 321 return true; |
| 317 } | 322 } |
| 318 | 323 |
| 319 // static | 324 // static |
| 320 ThreadTicks ThreadTicks::Now() { | 325 ThreadTicks ThreadTicks::Now() { |
| 321 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ | 326 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ |
| 322 defined(OS_ANDROID) | 327 defined(OS_ANDROID) |
| 323 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); | 328 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); |
| 324 #else | 329 #else |
| (...skipping 29 matching lines...) Expand all Loading... |
| 354 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; | 359 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; |
| 355 return result; | 360 return result; |
| 356 } | 361 } |
| 357 int64_t us = us_ - kTimeTToMicrosecondsOffset; | 362 int64_t us = us_ - kTimeTToMicrosecondsOffset; |
| 358 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 363 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 359 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 364 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 360 return result; | 365 return result; |
| 361 } | 366 } |
| 362 | 367 |
| 363 } // namespace base | 368 } // namespace base |
| OLD | NEW |