Skip to content

Commit

Permalink
Use the tonic::HandleTable (flutter#3924)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianloic authored Jul 26, 2017
1 parent 8ee1910 commit 68d3553
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion content_handler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ template("flutter_content_handler") {
"//lib/fidl/dart/sdk_ext",
"//lib/ftl",
"//lib/mtl",
"//lib/tonic/mx",
"//lib/tonic",
"//lib/zip",
"//magma:vulkan",
"//third_party/rapidjson",
Expand Down
24 changes: 14 additions & 10 deletions content_handler/runtime_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
#include "lib/ftl/logging.h"
#include "lib/ftl/time/time_delta.h"
#include "lib/mtl/vmo/vector.h"
#include "lib/tonic/mx/mx_converter.h"
#include "lib/tonic/handle_table.h"
#include "lib/zip/create_unzipper.h"
#include "third_party/rapidjson/rapidjson/document.h"
#include "third_party/rapidjson/rapidjson/stringbuffer.h"
#include "third_party/rapidjson/rapidjson/writer.h"

using tonic::DartConverter;
using tonic::HandleTable;
using tonic::ToDart;

namespace flutter_runner {
Expand Down Expand Up @@ -364,13 +365,15 @@ void RuntimeHolder::InitFidlInternal() {
DART_CHECK_VALID(Dart_SetNativeResolver(
fidl_internal, fidl::dart::NativeLookup, fidl::dart::NativeSymbol));

DART_CHECK_VALID(Dart_SetField(
fidl_internal, ToDart("_environment"),
DartConverter<mx::channel>::ToDart(environment.PassHandle())));
HandleTable& handle_table = HandleTable::Current();

DART_CHECK_VALID(Dart_SetField(
fidl_internal, ToDart("_outgoingServices"),
DartConverter<mx::channel>::ToDart(outgoing_services_.PassChannel())));
DART_CHECK_VALID(
Dart_SetField(fidl_internal, ToDart("_environment"),
handle_table.AddAndWrap(environment.PassHandle())));

DART_CHECK_VALID(
Dart_SetField(fidl_internal, ToDart("_outgoingServices"),
handle_table.AddAndWrap(outgoing_services_.PassChannel())));
}

void RuntimeHolder::InitMozartInternal() {
Expand All @@ -388,9 +391,10 @@ void RuntimeHolder::InitMozartInternal() {
DartConverter<uint64_t>::ToDart(reinterpret_cast<intptr_t>(
static_cast<mozart::NativesDelegate*>(this)))));

DART_CHECK_VALID(Dart_SetField(
mozart_internal, ToDart("_viewContainer"),
DartConverter<mx::channel>::ToDart(view_container.PassHandle())));
HandleTable& handle_table = HandleTable::Current();
DART_CHECK_VALID(
Dart_SetField(mozart_internal, ToDart("_viewContainer"),
handle_table.AddAndWrap(view_container.PassHandle())));
}

void RuntimeHolder::InitRootBundle(std::vector<char> bundle) {
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/compositing/scene_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "lib/tonic/dart_binding_macros.h"
#include "lib/tonic/dart_library_natives.h"

#if defined(OS_FUCHSIA)
#include "lib/tonic/handle_table.h"
#endif

namespace blink {

static void SceneHost_constructor(Dart_NativeArguments args) {
Expand All @@ -31,7 +35,8 @@ ftl::RefPtr<SceneHost> SceneHost::create(int export_token_handle) {

SceneHost::SceneHost(int export_token_handle) {
#if defined(OS_FUCHSIA)
export_node_ = ftl::MakeRefCounted<flow::ExportNode>(export_token_handle);
export_node_ = ftl::MakeRefCounted<flow::ExportNode>(
tonic::HandleTable::Current().Unwrap(export_token_handle));
#endif
}

Expand Down

0 comments on commit 68d3553

Please sign in to comment.