mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[fidl] Port Dart runtime to FIDL2.
Change-Id: I0423c17514027b282856f5796a550ceaa3b66baf Reviewed-on: https://dart-review.googlesource.com/48840 Reviewed-by: Zach Anderson <zra@google.com> Reviewed-by: Adam Barth <abarth@google.com>
This commit is contained in:
parent
d46dd1bd68
commit
477a773cdb
|
@ -71,7 +71,7 @@ template("build_libdart_vm") {
|
||||||
# TODO(US-399): Remove time_service specific code when it is no longer
|
# TODO(US-399): Remove time_service specific code when it is no longer
|
||||||
# necessary.
|
# necessary.
|
||||||
"//garnet/public/lib/app/cpp",
|
"//garnet/public/lib/app/cpp",
|
||||||
"//garnet/public/lib/time_service/fidl",
|
"//garnet/public/lib/time_zone/fidl",
|
||||||
|
|
||||||
# TODO(zra): When the platform-specific timeline code is moved out to
|
# TODO(zra): When the platform-specific timeline code is moved out to
|
||||||
# the embedder, this can go away.
|
# the embedder, this can go away.
|
||||||
|
|
|
@ -14,14 +14,13 @@
|
||||||
#include <zircon/syscalls/object.h>
|
#include <zircon/syscalls/object.h>
|
||||||
#include <zircon/types.h>
|
#include <zircon/types.h>
|
||||||
|
|
||||||
|
#include <fuchsia/cpp/time_zone.h>
|
||||||
|
|
||||||
#include "lib/app/cpp/environment_services.h"
|
#include "lib/app/cpp/environment_services.h"
|
||||||
#include "lib/time_service/fidl/time_service.fidl.h"
|
|
||||||
|
|
||||||
#include "platform/assert.h"
|
#include "platform/assert.h"
|
||||||
#include "vm/zone.h"
|
#include "vm/zone.h"
|
||||||
|
|
||||||
static constexpr char kTimeServiceName[] = "time_service::TimeService";
|
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
|
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
|
@ -42,17 +41,18 @@ intptr_t OS::ProcessId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static zx_status_t GetTimeServicePtr(
|
static zx_status_t GetTimeServicePtr(
|
||||||
time_service::TimeServiceSyncPtr* time_svc) {
|
time_zone::TimezoneSyncPtr* time_svc) {
|
||||||
zx::channel service_root = app::subtle::CreateStaticServiceRootHandle();
|
zx::channel service_root = app::subtle::CreateStaticServiceRootHandle();
|
||||||
zx::channel time_svc_channel = GetSynchronousProxy(time_svc).TakeChannel();
|
zx::channel time_svc_channel = time_svc->NewRequest().TakeChannel();
|
||||||
return fdio_service_connect_at(service_root.get(), kTimeServiceName,
|
return fdio_service_connect_at(service_root.get(),
|
||||||
|
time_zone::Timezone::Name_,
|
||||||
time_svc_channel.release());
|
time_svc_channel.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
static zx_status_t GetLocalAndDstOffsetInSeconds(int64_t seconds_since_epoch,
|
static zx_status_t GetLocalAndDstOffsetInSeconds(int64_t seconds_since_epoch,
|
||||||
int32_t* local_offset,
|
int32_t* local_offset,
|
||||||
int32_t* dst_offset) {
|
int32_t* dst_offset) {
|
||||||
time_service::TimeServiceSyncPtr time_svc;
|
time_zone::TimezoneSyncPtr time_svc;
|
||||||
zx_status_t status = GetTimeServicePtr(&time_svc);
|
zx_status_t status = GetTimeServicePtr(&time_svc);
|
||||||
if (status == ZX_OK) {
|
if (status == ZX_OK) {
|
||||||
time_svc->GetTimezoneOffsetMinutes(seconds_since_epoch * 1000, local_offset,
|
time_svc->GetTimezoneOffsetMinutes(seconds_since_epoch * 1000, local_offset,
|
||||||
|
@ -64,9 +64,9 @@ static zx_status_t GetLocalAndDstOffsetInSeconds(int64_t seconds_since_epoch,
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) {
|
const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) {
|
||||||
time_service::TimeServiceSyncPtr time_svc;
|
time_zone::TimezoneSyncPtr time_svc;
|
||||||
if (GetTimeServicePtr(&time_svc) == ZX_OK) {
|
if (GetTimeServicePtr(&time_svc) == ZX_OK) {
|
||||||
f1dl::String res;
|
fidl::StringPtr res;
|
||||||
time_svc->GetTimezoneId(&res);
|
time_svc->GetTimezoneId(&res);
|
||||||
char* tz_name = Thread::Current()->zone()->Alloc<char>(res->size() + 1);
|
char* tz_name = Thread::Current()->zone()->Alloc<char>(res->size() + 1);
|
||||||
memmove(tz_name, res->data(), res->size());
|
memmove(tz_name, res->data(), res->size());
|
||||||
|
|
Loading…
Reference in a new issue