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

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

Issue 2754013002: Format all dart: library files (Closed)
Patch Set: Format all dart: library files Created 3 years, 9 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 | « sdk/lib/developer/profiler.dart ('k') | sdk/lib/developer/timeline.dart » ('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) 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.
11 class ServiceProtocolInfo { 11 class ServiceProtocolInfo {
12 /// The major version of the protocol. If the running Dart environment does 12 /// The major version of the protocol. If the running Dart environment does
13 /// not support the service protocol, this is 0. 13 /// not support the service protocol, this is 0.
14 final int majorVersion = _getServiceMajorVersion(); 14 final int majorVersion = _getServiceMajorVersion();
15
15 /// The minor version of the protocol. If the running Dart environment does 16 /// The minor version of the protocol. If the running Dart environment does
16 /// not support the service protocol, this is 0. 17 /// not support the service protocol, this is 0.
17 final int minorVersion = _getServiceMinorVersion(); 18 final int minorVersion = _getServiceMinorVersion();
19
18 /// The Uri to access the service. If the web server is not running, this 20 /// The Uri to access the service. If the web server is not running, this
19 /// will be null. 21 /// will be null.
20 final Uri serverUri; 22 final Uri serverUri;
21 23
22 ServiceProtocolInfo(this.serverUri); 24 ServiceProtocolInfo(this.serverUri);
23 25
24 String toString() { 26 String toString() {
25 if (serverUri != null) { 27 if (serverUri != null) {
26 return 'Dart VM Service Protocol v$majorVersion.$minorVersion ' 28 return 'Dart VM Service Protocol v$majorVersion.$minorVersion '
27 'listening on $serverUri'; 29 'listening on $serverUri';
28 } else { 30 } else {
29 return 'Dart VM Service Protocol v$majorVersion.$minorVersion'; 31 return 'Dart VM Service Protocol v$majorVersion.$minorVersion';
30 } 32 }
31 } 33 }
32 } 34 }
33 35
34 /// Access information about the service protocol and control the web server 36 /// Access information about the service protocol and control the web server
35 /// that provides access to the services provided by the Dart VM for 37 /// that provides access to the services provided by the Dart VM for
36 /// debugging and inspecting Dart programs. 38 /// debugging and inspecting Dart programs.
37 class Service { 39 class Service {
(...skipping 12 matching lines...) Expand all
50 receivePort.close(); 52 receivePort.close();
51 return new ServiceProtocolInfo(uri); 53 return new ServiceProtocolInfo(uri);
52 } 54 }
53 55
54 /// Control the web server that the service protocol is accessed through. 56 /// Control the web server that the service protocol is accessed through.
55 /// The [enable] argument must be a boolean and is used as a toggle to 57 /// The [enable] argument must be a boolean and is used as a toggle to
56 /// enable(true) or disable(false) the web server servicing requests. 58 /// enable(true) or disable(false) the web server servicing requests.
57 static Future<ServiceProtocolInfo> controlWebServer( 59 static Future<ServiceProtocolInfo> controlWebServer(
58 {bool enable: false}) async { 60 {bool enable: false}) async {
59 if (enable is! bool) { 61 if (enable is! bool) {
60 throw new ArgumentError.value(enable, 62 throw new ArgumentError.value(enable, 'enable', 'Must be a bool');
61 'enable',
62 'Must be a bool');
63 } 63 }
64 // Port to receive response from service isolate. 64 // Port to receive response from service isolate.
65 final RawReceivePort receivePort = new RawReceivePort(); 65 final RawReceivePort receivePort = new RawReceivePort();
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 76
77 /// Returns a [String] token representing the ID of [isolate]. 77 /// Returns a [String] token representing the ID of [isolate].
78 /// 78 ///
79 /// Returns null if the running Dart environment does not support the service 79 /// Returns null if the running Dart environment does not support the service
80 /// protocol. 80 /// protocol.
81 static String getIsolateID(Isolate isolate) { 81 static String getIsolateID(Isolate isolate) {
82 if (isolate is! Isolate) { 82 if (isolate is! Isolate) {
83 throw new ArgumentError.value(isolate, 83 throw new ArgumentError.value(isolate, 'isolate', 'Must be an Isolate');
84 'isolate',
85 'Must be an Isolate');
86 } 84 }
87 return _getIsolateIDFromSendPort(isolate.controlPort); 85 return _getIsolateIDFromSendPort(isolate.controlPort);
88 } 86 }
89 } 87 }
90 88
91 /// [sendPort] will receive a Uri or null. 89 /// [sendPort] will receive a Uri or null.
92 external void _getServerInfo(SendPort sendPort); 90 external void _getServerInfo(SendPort sendPort);
93 91
94 /// [sendPort] will receive a Uri or null. 92 /// [sendPort] will receive a Uri or null.
95 external void _webServerControl(SendPort sendPort, bool enable); 93 external void _webServerControl(SendPort sendPort, bool enable);
96 94
97 /// Returns the major version of the service protocol. 95 /// Returns the major version of the service protocol.
98 external int _getServiceMajorVersion(); 96 external int _getServiceMajorVersion();
99 97
100 /// Returns the minor version of the service protocol. 98 /// Returns the minor version of the service protocol.
101 external int _getServiceMinorVersion(); 99 external int _getServiceMinorVersion();
102 100
103 /// Returns the service id for the isolate that owns [sendPort]. 101 /// Returns the service id for the isolate that owns [sendPort].
104 external String _getIsolateIDFromSendPort(SendPort sendPort); 102 external String _getIsolateIDFromSendPort(SendPort sendPort);
OLDNEW
« no previous file with comments | « sdk/lib/developer/profiler.dart ('k') | sdk/lib/developer/timeline.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698