| 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) | 10 #if defined(OS_ANDROID) |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 return Now(); | 304 return Now(); |
| 305 } | 305 } |
| 306 | 306 |
| 307 // static | 307 // static |
| 308 bool TimeTicks::IsHighResNowFastAndReliable() { | 308 bool TimeTicks::IsHighResNowFastAndReliable() { |
| 309 return true; | 309 return true; |
| 310 } | 310 } |
| 311 | 311 |
| 312 // static | 312 // static |
| 313 TimeTicks TimeTicks::ThreadNow() { | 313 TimeTicks TimeTicks::ThreadNow() { |
| 314 #if defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0) | 314 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ |
| 315 defined(OS_ANDROID) |
| 315 return ClockNow(CLOCK_THREAD_CPUTIME_ID); | 316 return ClockNow(CLOCK_THREAD_CPUTIME_ID); |
| 316 #else | 317 #else |
| 317 NOTREACHED(); | 318 NOTREACHED(); |
| 318 return TimeTicks(); | 319 return TimeTicks(); |
| 319 #endif | 320 #endif |
| 320 } | 321 } |
| 321 | 322 |
| 322 #if defined(OS_CHROMEOS) | 323 #if defined(OS_CHROMEOS) |
| 323 // Force definition of the system trace clock; it is a chromeos-only api | 324 // Force definition of the system trace clock; it is a chromeos-only api |
| 324 // at the moment and surfacing it in the right place requires mucking | 325 // at the moment and surfacing it in the right place requires mucking |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; | 381 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; |
| 381 return result; | 382 return result; |
| 382 } | 383 } |
| 383 int64 us = us_ - kTimeTToMicrosecondsOffset; | 384 int64 us = us_ - kTimeTToMicrosecondsOffset; |
| 384 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 385 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 385 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 386 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 386 return result; | 387 return result; |
| 387 } | 388 } |
| 388 | 389 |
| 389 } // namespace base | 390 } // namespace base |
| OLD | NEW |