Flutter Engine
The Flutter Engine
isolate_name_server_natives.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/lib/ui/isolate_name_server/isolate_name_server_natives.h"
6
7#include <string>
8
9#include "flutter/lib/ui/isolate_name_server/isolate_name_server.h"
10#include "flutter/lib/ui/ui_dart_state.h"
13
14namespace flutter {
15
17 const std::string& name) {
18 auto name_server = UIDartState::Current()->GetIsolateNameServer();
19 if (!name_server) {
20 return Dart_Null();
21 }
22 Dart_PortEx port = name_server->LookupIsolatePortByName(name);
23 if (port.port_id == ILLEGAL_PORT) {
24 return Dart_Null();
25 }
27}
28
30 const std::string& name) {
31 auto name_server = UIDartState::Current()->GetIsolateNameServer();
32 if (!name_server) {
33 return false;
34 }
36 Dart_SendPortGetIdEx(port_handle, &port);
37 if (!name_server->RegisterIsolatePortWithName(port, name)) {
38 return false;
39 }
40 return true;
41}
42
44 auto name_server = UIDartState::Current()->GetIsolateNameServer();
45 if (!name_server || !name_server->RemoveIsolateNameMapping(name)) {
46 return false;
47 }
48 return true;
49}
50
51} // namespace flutter
static Dart_Handle LookupPortByName(const std::string &name)
static bool RegisterPortWithName(Dart_Handle port_handle, const std::string &name)
static bool RemovePortNameMapping(const std::string &name)
std::shared_ptr< IsolateNameServer > GetIsolateNameServer() const
static UIDartState * Current()
#define ILLEGAL_PORT
Definition: dart_api.h:1535
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT Dart_Handle Dart_NewSendPortEx(Dart_PortEx portex_id)
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_SendPortGetIdEx(Dart_Handle port, Dart_PortEx *portex_id)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
Definition: switches.h:87
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32