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

Unified Diff: sdk/lib/developer/extension.dart

Issue 1680593004: dart:developer service extension fixes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/tests/service/udp_socket_service_test.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/developer/extension.dart
diff --git a/sdk/lib/developer/extension.dart b/sdk/lib/developer/extension.dart
index 309dca2f1f253b223b9b9cbbff839ea0abbcf508..cdacdaa1d18a2d5755f81d07241553582d1e72ea 100644
--- a/sdk/lib/developer/extension.dart
+++ b/sdk/lib/developer/extension.dart
@@ -28,13 +28,23 @@ class ServiceExtensionResponse {
}
/// Invalid method parameter(s) error code.
- static const kInvalidParams = -32602;
+ @deprecated static const kInvalidParams = invalidParams;
/// Generic extension error code.
- static const kExtensionError = -32000;
+ @deprecated static const kExtensionError = extensionError;
/// Maximum extension provided error code.
- static const kExtensionErrorMax = -32000;
+ @deprecated static const kExtensionErrorMax = extensionErrorMax;
/// Minimum extension provided error code.
- static const kExtensionErrorMin = -32016;
+ @deprecated static const kExtensionErrorMin = extensionErrorMin;
+
+ /// Invalid method parameter(s) error code.
+ static const invalidParams = -32602;
+ /// Generic extension error code.
+ static const extensionError = -32000;
+ /// Maximum extension provided error code.
+ static const extensionErrorMax = -32000;
+ /// Minimum extension provided error code.
+ static const extensionErrorMin = -32016;
+
static String _errorCodeMessage(int errorCode) {
_validateErrorCode(errorCode);
@@ -90,14 +100,27 @@ typedef Future<ServiceExtensionResponse>
/// Register a [ServiceExtensionHandler] that will be invoked in this isolate
/// for [method]. *NOTE*: Service protocol extensions must be registered
-/// in each isolate and users of extensions must always specify a target
-/// isolate.
+/// in each isolate.
+///
+/// *NOTE*: [method] must begin with 'ext.' and you should use the following
+/// structure to avoid conflicts with other packages: 'ext.package.command'.
+/// That is, immediately following the 'ext.' prefix, should be the registering
+/// package name followed by another period ('.') and then the command name.
+/// For example: 'ext.dart.io.getOpenFiles'.
+///
+/// Because service extensions are isolate specific, clients using extensions
+/// must always include an 'isolateId' parameter with each RPC.
void registerExtension(String method, ServiceExtensionHandler handler) {
if (method is! String) {
throw new ArgumentError.value(method,
'method',
'Must be a String');
}
+ if (!method.startsWith('ext.')) {
+ throw new ArgumentError.value(method,
+ 'method',
+ 'Must begin with ext.');
+ }
if (_lookupExtension(method) != null) {
throw new ArgumentError('Extension already registered: $method');
}
« no previous file with comments | « runtime/observatory/tests/service/udp_socket_service_test.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698