Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index 6f4fd03d4d14791d0f72abcb848b08fda3063987..3868b9ca7dd8ad18ef946a3f5d6da57e66553e73 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -585,6 +585,16 @@ void Service::InvokeMethod(Isolate* isolate, const Array& msg) { |
return; |
} |
+ if (ExtensionHandlerExists(method_name)) { |
+ InvokeExtensionHandler(method_name, |
+ param_keys, |
+ param_values, |
+ reply_port, |
+ seq); |
+ // The reply is posted asynchronously. |
+ return; |
+ } |
+ |
PrintUnrecognizedMethodError(&js); |
js.PostReply(); |
return; |
@@ -869,6 +879,46 @@ EmbedderServiceHandler* Service::FindRootEmbedderHandler( |
} |
+bool Service::ExtensionHandlerExists(const String& method) { |
+ ASSERT(!method.IsNull()); |
+ const Library& developer_lib = Library::Handle(Library::DeveloperLibrary()); |
+ ASSERT(!developer_lib.IsNull()); |
+ const Function& extension_exists = Function::Handle( |
+ developer_lib.LookupLocalFunction(Symbols::_extensionExists())); |
+ ASSERT(!extension_exists.IsNull()); |
+ const Array& arguments = Array::Handle(Array::New(1)); |
+ ASSERT(!arguments.IsNull()); |
+ arguments.SetAt(0, method); |
+ return (DartEntry::InvokeFunction(extension_exists, arguments) == |
+ Object::bool_true().raw()); |
+} |
+ |
+ |
+bool Service::InvokeExtensionHandler(const String& method_name, |
+ const Array& parameter_keys, |
+ const Array& parameter_values, |
+ const Instance& reply_port, |
+ const Instance& id) { |
+ ASSERT(!method_name.IsNull()); |
+ ASSERT(!parameter_keys.IsNull()); |
+ ASSERT(!parameter_values.IsNull()); |
+ ASSERT(!reply_port.IsNull()); |
+ const Library& developer_lib = Library::Handle(Library::DeveloperLibrary()); |
+ ASSERT(!developer_lib.IsNull()); |
+ const Function& invoke_extension = Function::Handle( |
+ developer_lib.LookupLocalFunction(Symbols::_invokeExtension())); |
+ ASSERT(!invoke_extension.IsNull()); |
+ const Array& arguments = Array::Handle(Array::New(5)); |
+ arguments.SetAt(0, method_name); |
+ arguments.SetAt(1, parameter_keys); |
+ arguments.SetAt(2, parameter_values); |
+ arguments.SetAt(3, reply_port); |
+ arguments.SetAt(4, id); |
+ return (DartEntry::InvokeFunction(invoke_extension, arguments) == |
+ Object::bool_true().raw()); |
+} |
+ |
+ |
static const MethodParameter* get_isolate_params[] = { |
ISOLATE_PARAMETER, |
NULL, |