Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 vmservice; | 5 part of vmservice; |
| 6 | 6 |
| 7 String methodNameFromUri(Uri uri) { | |
|
Ivan Posva
2015/02/14 01:09:51
Does this have to be a top-level method?
| |
| 8 if (uri == null) { | |
| 9 return ''; | |
| 10 } | |
| 11 if (uri.pathSegments.length == 0) { | |
| 12 return ''; | |
| 13 } | |
| 14 return uri.pathSegments[0]; | |
| 15 } | |
| 16 | |
| 7 class Message { | 17 class Message { |
| 8 final Completer _completer = new Completer.sync(); | 18 final Completer _completer = new Completer.sync(); |
| 9 bool get completed => _completer.isCompleted; | 19 bool get completed => _completer.isCompleted; |
| 10 /// Future of response. | 20 /// Future of response. |
| 11 Future<String> get response => _completer.future; | 21 Future<String> get response => _completer.future; |
| 12 | 22 |
| 13 // In new messages. | 23 // In new messages. |
| 14 final String method; | 24 final String method; |
| 15 | 25 |
| 16 // In old messages. | 26 // In old messages. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 27 return; | 37 return; |
| 28 } | 38 } |
| 29 path.add(segment); | 39 path.add(segment); |
| 30 }); | 40 }); |
| 31 } | 41 } |
| 32 | 42 |
| 33 Message.fromJsonRpc(this.method, Map rpcParams) { | 43 Message.fromJsonRpc(this.method, Map rpcParams) { |
| 34 params.addAll(rpcParams); | 44 params.addAll(rpcParams); |
| 35 } | 45 } |
| 36 | 46 |
| 47 Message.fromUri(Uri uri) : method = methodNameFromUri(uri) { | |
| 48 params.addAll(uri.queryParameters); | |
| 49 } | |
| 50 | |
| 37 dynamic toJson() { | 51 dynamic toJson() { |
| 38 return { | 52 return { |
| 39 'path': path, | 53 'path': path, |
| 40 'params': params | 54 'params': params |
| 41 }; | 55 }; |
| 42 } | 56 } |
| 43 | 57 |
| 44 // Calls toString on all non-String elements of [list]. We do this so all | 58 // Calls toString on all non-String elements of [list]. We do this so all |
| 45 // elements in the list are strings, making consumption by C++ simpler. | 59 // elements in the list are strings, making consumption by C++ simpler. |
| 46 // This has a side effect that boolean literal values like true become 'true' | 60 // This has a side effect that boolean literal values like true become 'true' |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 'params': params | 130 'params': params |
| 117 })); | 131 })); |
| 118 } | 132 } |
| 119 } | 133 } |
| 120 | 134 |
| 121 void sendIsolateServiceMessage(SendPort sp, List m) | 135 void sendIsolateServiceMessage(SendPort sp, List m) |
| 122 native "VMService_SendIsolateServiceMessage"; | 136 native "VMService_SendIsolateServiceMessage"; |
| 123 | 137 |
| 124 void sendRootServiceMessage(List m) | 138 void sendRootServiceMessage(List m) |
| 125 native "VMService_SendRootServiceMessage"; | 139 native "VMService_SendRootServiceMessage"; |
| OLD | NEW |