1 // Copyright 2018 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.
4 
5 #include "base/time/time.h"
6 
7 namespace base {
8 
9 // static
FromUptimeMillis(int64_t uptime_millis_value)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