1 | // Copyright 2013 The Flutter 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 "flutter/fml/time/time_point.h" |
6 | |
7 | #include "flutter/fml/build_config.h" |
8 | |
9 | #if defined(OS_FUCHSIA) |
10 | #include <zircon/syscalls.h> |
11 | #else |
12 | #include <chrono> |
13 | #endif |
14 | |
15 | namespace fml { |
16 | |
17 | #if defined(OS_FUCHSIA) |
18 | |
19 | // static |
20 | TimePoint TimePoint::Now() { |
21 | return TimePoint(zx_clock_get_monotonic()); |
22 | } |
23 | |
24 | #else |
25 | |
26 | TimePoint TimePoint::Now() { |
27 | // The base time is arbitrary; use the clock epoch for convenience. |
28 | const auto elapsed_time = std::chrono::steady_clock::now().time_since_epoch(); |
29 | return TimePoint( |
30 | std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed_time) |
31 | .count()); |
32 | } |
33 | |
34 | #endif |
35 | |
36 | } // namespace fml |
37 | |