flutter_flutter/fml/time/time_point.cc
Adam Barth 197feb5119
[fuchsia] Update zx_clock_get callers (#8998)
Fuchsia is changing zx_clock_get to return a zx_status_t. This change
prepares us for that change.
2019-05-17 16:37:28 -07:00

37 lines
793 B
C++

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/fml/time/time_point.h"
#include "flutter/fml/build_config.h"
#if defined(OS_FUCHSIA)
#include <zircon/syscalls.h>
#else
#include <chrono>
#endif
namespace fml {
#if defined(OS_FUCHSIA)
// static
TimePoint TimePoint::Now() {
return TimePoint(zx_clock_get_monotonic());
}
#else
TimePoint TimePoint::Now() {
// The base time is arbitrary; use the clock epoch for convenience.
const auto elapsed_time = std::chrono::steady_clock::now().time_since_epoch();
return TimePoint(
std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed_time)
.count());
}
#endif
} // namespace fml