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

Side by Side Diff: sdk/lib/developer/extension.dart

Issue 1527793004: Provide list of service protocol extensions in isolate and emit an event when one is registered (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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_event.cc ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 part of dart.developer; 5 part of dart.developer;
6 6
7 class ServiceExtensionResponse { 7 class ServiceExtensionResponse {
8 final String _result; 8 final String _result;
9 final int _errorCode; 9 final int _errorCode;
10 final String _errorDetail; 10 final String _errorDetail;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 }); 75 });
76 } 76 }
77 } 77 }
78 } 78 }
79 79
80 /// A service protocol extension handler. Registered with [registerExtension]. 80 /// A service protocol extension handler. Registered with [registerExtension].
81 /// 81 ///
82 /// Must complete to a [ServiceExtensionResponse]. 82 /// Must complete to a [ServiceExtensionResponse].
83 /// 83 ///
84 /// [method] - the method name. 84 /// [method] - the method name of the service protocol request.
85 /// [parameters] - the parameters. 85 /// [parameters] - A map holding the parameters to the service protocol request.
86 ///
87 /// *NOTE*: All parameter names and values are **encoded as strings**.
86 typedef Future<ServiceExtensionResponse> 88 typedef Future<ServiceExtensionResponse>
87 ServiceExtensionHandler(String method, Map parameters); 89 ServiceExtensionHandler(String method, Map<String, String> parameters);
88 90
89 /// Register a [ServiceExtensionHandler] that will be invoked in this isolate 91 /// Register a [ServiceExtensionHandler] that will be invoked in this isolate
90 /// for [method]. 92 /// for [method]. *NOTE*: Service protocol extensions must be registered
93 /// in each isolate and users of extensions must always specify a target
94 /// isolate.
91 void registerExtension(String method, ServiceExtensionHandler handler) { 95 void registerExtension(String method, ServiceExtensionHandler handler) {
92 if (method is! String) { 96 if (method is! String) {
93 throw new ArgumentError.value(method, 97 throw new ArgumentError.value(method,
94 'method', 98 'method',
95 'Must be a String'); 99 'Must be a String');
96 } 100 }
97 if (_lookupExtension(method) != null) { 101 if (_lookupExtension(method) != null) {
98 throw new ArgumentError('Extension already registered: $method'); 102 throw new ArgumentError('Extension already registered: $method');
99 } 103 }
100 if (handler is! ServiceExtensionHandler) { 104 if (handler is! ServiceExtensionHandler) {
101 throw new ArgumentError.value(handler, 105 throw new ArgumentError.value(handler,
102 'handler', 106 'handler',
103 'Must be a ServiceExtensionHandler'); 107 'Must be a ServiceExtensionHandler');
104 } 108 }
105 _registerExtension(method, handler); 109 _registerExtension(method, handler);
106 } 110 }
107 111
108 // Both of these functions are written inside C++ to avoid updating the data 112 // Both of these functions are written inside C++ to avoid updating the data
109 // structures in Dart, getting an OOB, and observing stale state. Do not move 113 // structures in Dart, getting an OOB, and observing stale state. Do not move
110 // these into Dart code unless you can ensure that the operations will can be 114 // these into Dart code unless you can ensure that the operations will can be
111 // done atomically. Native code lives in vm/isolate.cc- 115 // done atomically. Native code lives in vm/isolate.cc-
112 // LookupServiceExtensionHandler and RegisterServiceExtensionHandler. 116 // LookupServiceExtensionHandler and RegisterServiceExtensionHandler.
113 external ServiceExtensionHandler _lookupExtension(String method); 117 external ServiceExtensionHandler _lookupExtension(String method);
114 external _registerExtension(String method, ServiceExtensionHandler handler); 118 external _registerExtension(String method, ServiceExtensionHandler handler);
OLDNEW
« no previous file with comments | « runtime/vm/service_event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698