OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |