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

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

Issue 2542003002: Add getIsolateID to Service class in dart:developer (Closed)
Patch Set: fix test Created 4 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 | « sdk/lib/developer/developer.dart ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// Service protocol is the protocol that a client like the observatory 7 /// Service protocol is the protocol that a client like the observatory
8 /// could use to access the services provided by the Dart VM for 8 /// could use to access the services provided by the Dart VM for
9 /// debugging and inspecting Dart programs. This class encapsulates the 9 /// debugging and inspecting Dart programs. This class encapsulates the
10 /// version number and Uri for accessing this service. 10 /// version number and Uri for accessing this service.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 final Completer<Uri> uriCompleter = new Completer<Uri>(); 66 final Completer<Uri> uriCompleter = new Completer<Uri>();
67 receivePort.handler = (Uri uri) => uriCompleter.complete(uri); 67 receivePort.handler = (Uri uri) => uriCompleter.complete(uri);
68 // Request the information from the service isolate. 68 // Request the information from the service isolate.
69 _webServerControl(receivePort.sendPort, enable); 69 _webServerControl(receivePort.sendPort, enable);
70 // Await the response from the service isolate. 70 // Await the response from the service isolate.
71 Uri uri = await uriCompleter.future; 71 Uri uri = await uriCompleter.future;
72 // Close the port. 72 // Close the port.
73 receivePort.close(); 73 receivePort.close();
74 return new ServiceProtocolInfo(uri); 74 return new ServiceProtocolInfo(uri);
75 } 75 }
76
77 /// Returns a [String] token representing the ID of [isolate].
78 ///
79 /// Returns null if the running Dart environment does not support the service
80 /// protocol.
81 static String getIsolateID(Isolate isolate) {
82 if (isolate is! Isolate) {
83 throw new ArgumentError.value(isolate,
84 'isolate',
85 'Must be an Isolate');
86 }
87 return _getIsolateIDFromSendPort(isolate.controlPort);
88 }
76 } 89 }
77 90
78 /// [sp] will receive a Uri or null. 91 /// [sendPort] will receive a Uri or null.
79 external void _getServerInfo(SendPort sp); 92 external void _getServerInfo(SendPort sendPort);
80 93
81 /// [sp] will receive a Uri or null. 94 /// [sendPort] will receive a Uri or null.
82 external void _webServerControl(SendPort sp, bool enable); 95 external void _webServerControl(SendPort sendPort, bool enable);
83 96
84 /// Returns the major version of the service protocol. 97 /// Returns the major version of the service protocol.
85 external int _getServiceMajorVersion(); 98 external int _getServiceMajorVersion();
86 99
87 /// Returns the minor version of the service protocol. 100 /// Returns the minor version of the service protocol.
88 external int _getServiceMinorVersion(); 101 external int _getServiceMinorVersion();
89 102
103 /// Returns the service id for the isolate that owns [sendPort].
104 external String _getIsolateIDFromSendPort(SendPort sendPort);
OLDNEW
« no previous file with comments | « sdk/lib/developer/developer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698