| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 TimeTicks::Clock TimeTicks::GetClock() { | 333 TimeTicks::Clock TimeTicks::GetClock() { |
| 334 return Clock::LINUX_CLOCK_MONOTONIC; | 334 return Clock::LINUX_CLOCK_MONOTONIC; |
| 335 } | 335 } |
| 336 | 336 |
| 337 // static | 337 // static |
| 338 bool TimeTicks::IsHighResolution() { | 338 bool TimeTicks::IsHighResolution() { |
| 339 return true; | 339 return true; |
| 340 } | 340 } |
| 341 | 341 |
| 342 // static | 342 // static |
| 343 bool TimeTicks::IsConsistentAcrossProcesses() { |
| 344 return true; |
| 345 } |
| 346 |
| 347 // static |
| 343 ThreadTicks ThreadTicks::Now() { | 348 ThreadTicks ThreadTicks::Now() { |
| 344 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ | 349 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ |
| 345 defined(OS_ANDROID) | 350 defined(OS_ANDROID) |
| 346 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); | 351 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); |
| 347 #else | 352 #else |
| 348 NOTREACHED(); | 353 NOTREACHED(); |
| 349 return ThreadTicks(); | 354 return ThreadTicks(); |
| 350 #endif | 355 #endif |
| 351 } | 356 } |
| 352 | 357 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 377 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; | 382 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; |
| 378 return result; | 383 return result; |
| 379 } | 384 } |
| 380 int64_t us = us_ - kTimeTToMicrosecondsOffset; | 385 int64_t us = us_ - kTimeTToMicrosecondsOffset; |
| 381 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 386 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 382 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 387 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 383 return result; | 388 return result; |
| 384 } | 389 } |
| 385 | 390 |
| 386 } // namespace base | 391 } // namespace base |
| OLD | NEW |