Flutter Engine
time_point.cc
Go to the documentation of this file.
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 #include "flutter/fml/logging.h"
9 #include "flutter/fml/time/dart_timestamp_provider.h"
10 
11 #if defined(OS_FUCHSIA)
12 #include <zircon/syscalls.h>
13 #else
14 #include <chrono>
15 #endif
16 
17 namespace fml {
18 
19 #if defined(OS_FUCHSIA)
20 
21 // static
22 TimePoint TimePoint::Now() {
23  return TimePoint(zx_clock_get_monotonic());
24 }
25 
27  return Now();
28 }
29 
30 #else
31 
32 template <typename Clock, typename Duration>
33 static int64_t NanosSinceEpoch(
34  std::chrono::time_point<Clock, Duration> time_point) {
35  const auto elapsed = time_point.time_since_epoch();
36  return std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed).count();
37 }
38 
41 }
42 
44  const int64_t nanos = NanosSinceEpoch(std::chrono::system_clock::now());
45  return TimePoint(nanos);
46 }
47 
48 #endif
49 
50 } // namespace fml
Definition: ascii_trie.cc:9
static TimePoint CurrentWallTime()
Definition: time_point.cc:43
constexpr TimePoint()=default
fml::TimePoint DartTimelineTicksSinceEpoch()
static int64_t NanosSinceEpoch(std::chrono::time_point< Clock, Duration > time_point)
Definition: time_point.cc:33
static TimePoint Now()
Definition: time_point.cc:39