Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: runtime/vm/service.cc

Issue 1282883003: Move service extension handler execution to a timer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/service.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 if (handler == NULL) { 578 if (handler == NULL) {
579 handler = FindRootEmbedderHandler(c_method_name); 579 handler = FindRootEmbedderHandler(c_method_name);
580 } 580 }
581 581
582 if (handler != NULL) { 582 if (handler != NULL) {
583 EmbedderHandleMessage(handler, &js); 583 EmbedderHandleMessage(handler, &js);
584 js.PostReply(); 584 js.PostReply();
585 return; 585 return;
586 } 586 }
587 587
588 if (ExtensionHandlerExists(method_name)) { 588 if (ScheduleExtensionHandler(method_name,
589 InvokeExtensionHandler(method_name, 589 param_keys,
590 param_keys, 590 param_values,
591 param_values, 591 reply_port,
592 reply_port, 592 seq)) {
593 seq); 593 // Schedule was successful. Extension code will post a reply
594 // The reply is posted asynchronously. 594 // asynchronously.
595 return; 595 return;
596 } 596 }
597 597
598 PrintUnrecognizedMethodError(&js); 598 PrintUnrecognizedMethodError(&js);
599 js.PostReply(); 599 js.PostReply();
600 return; 600 return;
601 } 601 }
602 } 602 }
603 603
604 604
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 while (current != NULL) { 872 while (current != NULL) {
873 if (strcmp(name, current->name()) == 0) { 873 if (strcmp(name, current->name()) == 0) {
874 return current; 874 return current;
875 } 875 }
876 current = current->next(); 876 current = current->next();
877 } 877 }
878 return NULL; 878 return NULL;
879 } 879 }
880 880
881 881
882 bool Service::ExtensionHandlerExists(const String& method) { 882 bool Service::ScheduleExtensionHandler(const String& method_name,
883 ASSERT(!method.IsNull()); 883 const Array& parameter_keys,
884 const Library& developer_lib = Library::Handle(Library::DeveloperLibrary()); 884 const Array& parameter_values,
885 ASSERT(!developer_lib.IsNull()); 885 const Instance& reply_port,
886 const Function& extension_exists = Function::Handle( 886 const Instance& id) {
887 developer_lib.LookupLocalFunction(Symbols::_extensionExists()));
888 ASSERT(!extension_exists.IsNull());
889 const Array& arguments = Array::Handle(Array::New(1));
890 ASSERT(!arguments.IsNull());
891 arguments.SetAt(0, method);
892 return (DartEntry::InvokeFunction(extension_exists, arguments) ==
893 Object::bool_true().raw());
894 }
895
896
897 bool Service::InvokeExtensionHandler(const String& method_name,
898 const Array& parameter_keys,
899 const Array& parameter_values,
900 const Instance& reply_port,
901 const Instance& id) {
902 ASSERT(!method_name.IsNull()); 887 ASSERT(!method_name.IsNull());
903 ASSERT(!parameter_keys.IsNull()); 888 ASSERT(!parameter_keys.IsNull());
904 ASSERT(!parameter_values.IsNull()); 889 ASSERT(!parameter_values.IsNull());
905 ASSERT(!reply_port.IsNull()); 890 ASSERT(!reply_port.IsNull());
906 const Library& developer_lib = Library::Handle(Library::DeveloperLibrary()); 891 const Library& developer_lib = Library::Handle(Library::DeveloperLibrary());
907 ASSERT(!developer_lib.IsNull()); 892 ASSERT(!developer_lib.IsNull());
908 const Function& invoke_extension = Function::Handle( 893 const Function& schedule_extension = Function::Handle(
909 developer_lib.LookupLocalFunction(Symbols::_invokeExtension())); 894 developer_lib.LookupLocalFunction(Symbols::_scheduleExtension()));
910 ASSERT(!invoke_extension.IsNull()); 895 ASSERT(!schedule_extension.IsNull());
911 const Array& arguments = Array::Handle(Array::New(5)); 896 const Array& arguments = Array::Handle(Array::New(5));
912 arguments.SetAt(0, method_name); 897 arguments.SetAt(0, method_name);
913 arguments.SetAt(1, parameter_keys); 898 arguments.SetAt(1, parameter_keys);
914 arguments.SetAt(2, parameter_values); 899 arguments.SetAt(2, parameter_values);
915 arguments.SetAt(3, reply_port); 900 arguments.SetAt(3, reply_port);
916 arguments.SetAt(4, id); 901 arguments.SetAt(4, id);
917 return (DartEntry::InvokeFunction(invoke_extension, arguments) == 902 return (DartEntry::InvokeFunction(schedule_extension, arguments) ==
918 Object::bool_true().raw()); 903 Object::bool_true().raw());
919 } 904 }
920 905
921 906
922 static const MethodParameter* get_isolate_params[] = { 907 static const MethodParameter* get_isolate_params[] = {
923 ISOLATE_PARAMETER, 908 ISOLATE_PARAMETER,
924 NULL, 909 NULL,
925 }; 910 };
926 911
927 912
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 ServiceMethodDescriptor& method = service_methods_[i]; 3119 ServiceMethodDescriptor& method = service_methods_[i];
3135 if (strcmp(method_name, method.name) == 0) { 3120 if (strcmp(method_name, method.name) == 0) {
3136 return &method; 3121 return &method;
3137 } 3122 }
3138 } 3123 }
3139 return NULL; 3124 return NULL;
3140 } 3125 }
3141 3126
3142 3127
3143 } // namespace dart 3128 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698