@@ -35,17 +35,29 @@ namespace blink {
35
35
namespace {
36
36
37
37
static tonic::DartLibraryNatives* g_natives;
38
+ static tonic::DartLibraryNatives* g_natives_secondary;
38
39
39
40
Dart_NativeFunction GetNativeFunction (Dart_Handle name,
40
41
int argument_count,
41
42
bool * auto_setup_scope) {
42
43
return g_natives->GetNativeFunction (name, argument_count, auto_setup_scope);
43
44
}
44
45
46
+ Dart_NativeFunction GetNativeFunctionSecondary (Dart_Handle name,
47
+ int argument_count,
48
+ bool * auto_setup_scope) {
49
+ return g_natives_secondary->GetNativeFunction (name, argument_count,
50
+ auto_setup_scope);
51
+ }
52
+
45
53
const uint8_t * GetSymbol (Dart_NativeFunction native_function) {
46
54
return g_natives->GetSymbol (native_function);
47
55
}
48
56
57
+ const uint8_t * GetSymbolSecondary (Dart_NativeFunction native_function) {
58
+ return g_natives_secondary->GetSymbol (native_function);
59
+ }
60
+
49
61
} // namespace
50
62
51
63
void DartUI::InitForGlobal () {
@@ -73,13 +85,20 @@ void DartUI::InitForGlobal() {
73
85
SemanticsUpdateBuilder::RegisterNatives (g_natives);
74
86
Vertices::RegisterNatives (g_natives);
75
87
Window::RegisterNatives (g_natives);
88
+
89
+ // Secondary isolates do not provide UI-related APIs.
90
+ g_natives_secondary = new tonic::DartLibraryNatives ();
91
+ DartRuntimeHooks::RegisterNatives (g_natives_secondary);
76
92
}
77
93
}
78
94
79
- void DartUI::InitForIsolate () {
95
+ void DartUI::InitForIsolate (bool is_root_isolate ) {
80
96
FML_DCHECK (g_natives);
97
+ auto get_native_function =
98
+ is_root_isolate ? GetNativeFunction : GetNativeFunctionSecondary;
99
+ auto get_symbol = is_root_isolate ? GetSymbol : GetSymbolSecondary;
81
100
DART_CHECK_VALID (Dart_SetNativeResolver (Dart_LookupLibrary (ToDart (" dart:ui" )),
82
- GetNativeFunction, GetSymbol ));
101
+ get_native_function, get_symbol ));
83
102
}
84
103
85
104
} // namespace blink
0 commit comments