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

Side by Side Diff: runtime/lib/developer.dart

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: 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 | « runtime/lib/deferred_load_patch.dart ('k') | runtime/lib/double.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) 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 import 'dart:isolate'; 5 import 'dart:isolate';
6 import 'dart:_internal' hide Symbol; 6 import 'dart:_internal' hide Symbol;
7 7
8 @patch 8 @patch bool debugger({bool when: true,
9 bool debugger({bool when: true, String message}) native "Developer_debugger"; 9 String message}) native "Developer_debugger";
10 10
11 @patch 11 @patch Object inspect(Object object) native "Developer_inspect";
12 Object inspect(Object object) native "Developer_inspect";
13 12
14 @patch 13 @patch void log(String message,
15 void log(String message, 14 {DateTime time,
16 {DateTime time, 15 int sequenceNumber,
17 int sequenceNumber, 16 int level: 0,
18 int level: 0, 17 String name: '',
19 String name: '', 18 Zone zone,
20 Zone zone, 19 Object error,
21 Object error, 20 StackTrace stackTrace}) {
22 StackTrace stackTrace}) {
23 if (message is! String) { 21 if (message is! String) {
24 throw new ArgumentError.value(message, "message", "Must be a String"); 22 throw new ArgumentError.value(message, "message", "Must be a String");
25 } 23 }
26 if (time == null) { 24 if (time == null) {
27 time = new DateTime.now(); 25 time = new DateTime.now();
28 } 26 }
29 if (time is! DateTime) { 27 if (time is! DateTime) {
30 throw new ArgumentError.value(time, "time", "Must be a DateTime"); 28 throw new ArgumentError.value(time, "time", "Must be a DateTime");
31 } 29 }
32 if (sequenceNumber == null) { 30 if (sequenceNumber == null) {
33 sequenceNumber = _nextSequenceNumber++; 31 sequenceNumber = _nextSequenceNumber++;
34 } else { 32 } else {
35 _nextSequenceNumber = sequenceNumber + 1; 33 _nextSequenceNumber = sequenceNumber + 1;
36 } 34 }
37 _log(message, time.millisecondsSinceEpoch, sequenceNumber, level, name, zone, 35 _log(message,
38 error, stackTrace); 36 time.millisecondsSinceEpoch,
37 sequenceNumber,
38 level,
39 name,
40 zone,
41 error,
42 stackTrace);
39 } 43 }
40 44
41 int _nextSequenceNumber = 0; 45 int _nextSequenceNumber = 0;
42 46
43 _log(String message, int timestamp, int sequenceNumber, int level, String name, 47 _log(String message,
44 Zone zone, Object error, StackTrace stackTrace) native "Developer_log"; 48 int timestamp,
49 int sequenceNumber,
50 int level,
51 String name,
52 Zone zone,
53 Object error,
54 StackTrace stackTrace) native "Developer_log";
45 55
46 @patch 56 @patch void _postEvent(String eventKind, String eventData)
47 void _postEvent(String eventKind, String eventData)
48 native "Developer_postEvent"; 57 native "Developer_postEvent";
49 58
50 @patch 59 @patch ServiceExtensionHandler _lookupExtension(String method)
51 ServiceExtensionHandler _lookupExtension(String method)
52 native "Developer_lookupExtension"; 60 native "Developer_lookupExtension";
53 61
54 @patch 62 @patch _registerExtension(String method, ServiceExtensionHandler handler)
55 _registerExtension(String method, ServiceExtensionHandler handler)
56 native "Developer_registerExtension"; 63 native "Developer_registerExtension";
57 64
58 // This code is only invoked when there is no other Dart code on the stack. 65 // This code is only invoked when there is no other Dart code on the stack.
59 _runExtension( 66 _runExtension(ServiceExtensionHandler handler,
60 ServiceExtensionHandler handler, 67 String method,
61 String method, 68 List<String> parameterKeys,
62 List<String> parameterKeys, 69 List<String> parameterValues,
63 List<String> parameterValues, 70 SendPort replyPort,
64 SendPort replyPort, 71 Object id,
65 Object id, 72 bool trace_service) {
66 bool trace_service) {
67 var parameters = {}; 73 var parameters = {};
68 for (var i = 0; i < parameterKeys.length; i++) { 74 for (var i = 0; i < parameterKeys.length; i++) {
69 parameters[parameterKeys[i]] = parameterValues[i]; 75 parameters[parameterKeys[i]] = parameterValues[i];
70 } 76 }
71 var response; 77 var response;
72 try { 78 try {
73 response = handler(method, parameters); 79 response = handler(method, parameters);
74 } catch (e, st) { 80 } catch (e, st) {
75 var errorDetails = (st == null) ? '$e' : '$e\n$st'; 81 var errorDetails = (st == null) ? '$e' : '$e\n$st';
76 response = new ServiceExtensionResponse.error( 82 response = new ServiceExtensionResponse.error(
77 ServiceExtensionResponse.kExtensionError, errorDetails); 83 ServiceExtensionResponse.kExtensionError,
84 errorDetails);
78 _postResponse(replyPort, id, response, trace_service); 85 _postResponse(replyPort, id, response, trace_service);
79 return; 86 return;
80 } 87 }
81 if (response is! Future) { 88 if (response is! Future) {
82 response = new ServiceExtensionResponse.error( 89 response = new ServiceExtensionResponse.error(
83 ServiceExtensionResponse.kExtensionError, 90 ServiceExtensionResponse.kExtensionError,
84 "Extension handler must return a Future"); 91 "Extension handler must return a Future");
85 _postResponse(replyPort, id, response, trace_service); 92 _postResponse(replyPort, id, response, trace_service);
86 return; 93 return;
87 } 94 }
88 response.catchError((e, st) { 95 response.catchError((e, st) {
89 // Catch any errors eagerly and wrap them in a ServiceExtensionResponse. 96 // Catch any errors eagerly and wrap them in a ServiceExtensionResponse.
90 var errorDetails = (st == null) ? '$e' : '$e\n$st'; 97 var errorDetails = (st == null) ? '$e' : '$e\n$st';
91 return new ServiceExtensionResponse.error( 98 return new ServiceExtensionResponse.error(
92 ServiceExtensionResponse.kExtensionError, errorDetails); 99 ServiceExtensionResponse.kExtensionError,
100 errorDetails);
93 }).then((response) { 101 }).then((response) {
94 // Post the valid response or the wrapped error after verifying that 102 // Post the valid response or the wrapped error after verifying that
95 // the response is a ServiceExtensionResponse. 103 // the response is a ServiceExtensionResponse.
96 if (response is! ServiceExtensionResponse) { 104 if (response is! ServiceExtensionResponse) {
97 response = new ServiceExtensionResponse.error( 105 response = new ServiceExtensionResponse.error(
98 ServiceExtensionResponse.kExtensionError, 106 ServiceExtensionResponse.kExtensionError,
99 "Extension handler must complete to a ServiceExtensionResponse"); 107 "Extension handler must complete to a ServiceExtensionResponse");
100 } 108 }
101 _postResponse(replyPort, id, response, trace_service); 109 _postResponse(replyPort, id, response, trace_service);
102 }).catchError((e, st) { 110 }).catchError((e, st) {
103 // We do not expect any errors to occur in the .then or .catchError blocks 111 // We do not expect any errors to occur in the .then or .catchError blocks
104 // but, suppress them just in case. 112 // but, suppress them just in case.
105 }); 113 });
106 } 114 }
107 115
108 // This code is only invoked by _runExtension. 116 // This code is only invoked by _runExtension.
109 _postResponse(SendPort replyPort, Object id, ServiceExtensionResponse response, 117 _postResponse(SendPort replyPort,
110 bool trace_service) { 118 Object id,
119 ServiceExtensionResponse response,
120 bool trace_service) {
111 assert(replyPort != null); 121 assert(replyPort != null);
112 if (id == null) { 122 if (id == null) {
113 if (trace_service) { 123 if (trace_service) {
114 print("vm-service: posting no response for request"); 124 print("vm-service: posting no response for request");
115 } 125 }
116 // No id -> no response. 126 // No id -> no response.
117 replyPort.send(null); 127 replyPort.send(null);
118 return; 128 return;
119 } 129 }
120 assert(id != null); 130 assert(id != null);
(...skipping 12 matching lines...) Expand all
133 } 143 }
134 sb.write('${response._toString()},'); 144 sb.write('${response._toString()},');
135 if (id is String) { 145 if (id is String) {
136 sb.write('"id":"$id"}'); 146 sb.write('"id":"$id"}');
137 } else { 147 } else {
138 sb.write('"id":$id}'); 148 sb.write('"id":$id}');
139 } 149 }
140 replyPort.send(sb.toString()); 150 replyPort.send(sb.toString());
141 } 151 }
142 152
143 @patch 153 @patch int _getServiceMajorVersion() native "Developer_getServiceMajorVersion";
144 int _getServiceMajorVersion() native "Developer_getServiceMajorVersion";
145 154
146 @patch 155 @patch int _getServiceMinorVersion() native "Developer_getServiceMinorVersion";
147 int _getServiceMinorVersion() native "Developer_getServiceMinorVersion";
148 156
149 @patch 157 @patch void _getServerInfo(SendPort sendPort) native "Developer_getServerInfo";
150 void _getServerInfo(SendPort sendPort) native "Developer_getServerInfo";
151 158
152 @patch 159 @patch void _webServerControl(SendPort sendPort, bool enable)
153 void _webServerControl(SendPort sendPort, bool enable)
154 native "Developer_webServerControl"; 160 native "Developer_webServerControl";
155 161
156 @patch 162 @patch String _getIsolateIDFromSendPort(SendPort sendPort)
157 String _getIsolateIDFromSendPort(SendPort sendPort)
158 native "Developer_getIsolateIDFromSendPort"; 163 native "Developer_getIsolateIDFromSendPort";
OLDNEW
« no previous file with comments | « runtime/lib/deferred_load_patch.dart ('k') | runtime/lib/double.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698