| 6 |
| 7 | namespace base { |
| 8 |
| 9 | // static |
| 10 | TimeTicks TimeTicks::FromUptimeMillis(int64_t uptime_millis_value) { |
| 11 | // The implementation of the SystemClock.uptimeMillis() in AOSP uses the same |
| 12 | // clock as base::TimeTicks::Now(): clock_gettime(CLOCK_MONOTONIC), see in |
| 13 | // platform/system/code: |
| 14 | // 1. libutils/SystemClock.cpp |
| 15 | // 2. libutils/Timers.cpp |
| 16 | // |
| 17 | // We are not aware of any motivations for Android OEMs to modify the AOSP |
| 18 | // implementation of either uptimeMillis() or clock_gettime(CLOCK_MONOTONIC), |
| 19 | // so we assume that there are no such customizations. |
| 20 | // |
| 21 | // Under these assumptions the conversion is as safe as copying the value of |
| 22 | // base::TimeTicks::Now() with a loss of sub-millisecond precision. |
| 23 | return TimeTicks(uptime_millis_value * Time::kMicrosecondsPerMillisecond); |
| 24 | } |
| 25 |
| 26 | } // namespace base |
| 27 |