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

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

Issue 1285673003: When no service response is requested, send null back to the service isolate so it can cleanup (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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/vm/service/message.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) 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 }); 151 });
152 return true; 152 return true;
153 } 153 }
154 154
155 _postResponse(SendPort replyPort, 155 _postResponse(SendPort replyPort,
156 Object id, 156 Object id,
157 ServiceExtensionResponse response) { 157 ServiceExtensionResponse response) {
158 assert(replyPort != null); 158 assert(replyPort != null);
159 if (id == null) { 159 if (id == null) {
160 // No id -> no response. 160 // No id -> no response.
161 // TODO(johnmccutchan): This code and the code in service.cc leave the 161 replyPort.send(null);
162 // service isolate with an open port. Consider posting 'null' to indicate
163 // that no response is coming.
164 return; 162 return;
165 } 163 }
166 assert(id != null); 164 assert(id != null);
167 StringBuffer sb = new StringBuffer(); 165 StringBuffer sb = new StringBuffer();
168 sb.write('{"jsonrpc":"2.0",'); 166 sb.write('{"jsonrpc":"2.0",');
169 if (response._isError()) { 167 if (response._isError()) {
170 sb.write('"error":'); 168 sb.write('"error":');
171 } else { 169 } else {
172 sb.write('"result":'); 170 sb.write('"result":');
173 } 171 }
174 sb.write('${response._toString()},'); 172 sb.write('${response._toString()},');
175 if (id is String) { 173 if (id is String) {
176 sb.write('"id":"$id"}'); 174 sb.write('"id":"$id"}');
177 } else { 175 } else {
178 sb.write('"id":$id}'); 176 sb.write('"id":$id}');
179 } 177 }
180 replyPort.send(sb.toString()); 178 replyPort.send(sb.toString());
181 } 179 }
OLDNEW
« no previous file with comments | « runtime/vm/service/message.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698