[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:
Ian McKellar 2018-03-30 05:23:36 +00:00 committed by Zach Anderson
parent d46dd1bd68
commit 477a773cdb
2 changed files with 10 additions and 10 deletions

View file

@ -71,7 +71,7 @@ template("build_libdart_vm") {
# TODO(US-399): Remove time_service specific code when it is no longer
# necessary.
"//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
# the embedder, this can go away.

View file

@ -14,14 +14,13 @@
#include <zircon/syscalls/object.h>
#include <zircon/types.h>
#include <fuchsia/cpp/time_zone.h>
#include "lib/app/cpp/environment_services.h"
#include "lib/time_service/fidl/time_service.fidl.h"
#include "platform/assert.h"
#include "vm/zone.h"
static constexpr char kTimeServiceName[] = "time_service::TimeService";
namespace dart {
#ifndef PRODUCT
@ -42,17 +41,18 @@ intptr_t OS::ProcessId() {
}
static zx_status_t GetTimeServicePtr(
time_service::TimeServiceSyncPtr* time_svc) {
time_zone::TimezoneSyncPtr* time_svc) {
zx::channel service_root = app::subtle::CreateStaticServiceRootHandle();
zx::channel time_svc_channel = GetSynchronousProxy(time_svc).TakeChannel();
return fdio_service_connect_at(service_root.get(), kTimeServiceName,
zx::channel time_svc_channel = time_svc->NewRequest().TakeChannel();
return fdio_service_connect_at(service_root.get(),
time_zone::Timezone::Name_,
time_svc_channel.release());
}
static zx_status_t GetLocalAndDstOffsetInSeconds(int64_t seconds_since_epoch,
int32_t* local_offset,
int32_t* dst_offset) {
time_service::TimeServiceSyncPtr time_svc;
time_zone::TimezoneSyncPtr time_svc;
zx_status_t status = GetTimeServicePtr(&time_svc);
if (status == ZX_OK) {
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) {
time_service::TimeServiceSyncPtr time_svc;
time_zone::TimezoneSyncPtr time_svc;
if (GetTimeServicePtr(&time_svc) == ZX_OK) {
f1dl::String res;
fidl::StringPtr res;
time_svc->GetTimezoneId(&res);
char* tz_name = Thread::Current()->zone()->Alloc<char>(res->size() + 1);
memmove(tz_name, res->data(), res->size());