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

Unified Diff: runtime/vm/service/message.dart

Issue 823403004: Begin migrating the vm service from a rest-style interface to a json-rpc style interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove old-style standalone tests. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/service/protocol.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service/message.dart
diff --git a/runtime/vm/service/message.dart b/runtime/vm/service/message.dart
index 6a7c66bca97564d565c07482d5b3db596d0d03d4..86f57c1eebaab3474eb45617d2be7d9d3003246a 100644
--- a/runtime/vm/service/message.dart
+++ b/runtime/vm/service/message.dart
@@ -9,10 +9,16 @@ class Message {
bool get completed => _completer.isCompleted;
/// Future of response.
Future<String> get response => _completer.future;
- /// Path.
+
+ final bool isOld;
+
+ // In new messages.
+ final String method;
+
+ // In old messages.
final List path = new List();
- /// Options.
- final Map options = new Map();
+
+ final Map params = new Map();
void _setPath(List<String> pathSegments) {
if (pathSegments == null) {
@@ -26,27 +32,33 @@ class Message {
});
}
- Message.fromUri(Uri uri) {
+ Message.fromUri(Uri uri) : isOld = true {
var split = uri.path.split('/');
if (split.length == 0) {
setErrorResponse('Invalid uri: $uri.');
return;
}
_setPath(split);
- options.addAll(uri.queryParameters);
+ params.addAll(uri.queryParameters);
+ }
+
+ Message.fromJsonRpc(this.method, Map rpcParams)
+ : isOld = false {
+ params.addAll(rpcParams);
}
- Message.fromMap(Map map) {
+ Message.fromMap(Map map) : isOld = true {
_setPath(map['path']);
+ // TODO - turnidge - change this to params in sender.
if (map['options'] != null) {
- options.addAll(map['options']);
+ params.addAll(map['options']);
}
}
dynamic toJson() {
return {
'path': path,
- 'options': options
+ 'params': params
};
}
@@ -60,12 +72,12 @@ class Message {
_completer.complete(value);
}
};
- var keys = options.keys.toList(growable:false);
- var values = options.values.toList(growable:false);
+ var keys = params.keys.toList(growable:false);
+ var values = params.values.toList(growable:false);
var request = new List(5)
..[0] = 0 // Make room for OOB message type.
..[1] = receivePort.sendPort
- ..[2] = path
+ ..[2] = (isOld ? path : method)
..[3] = keys
..[4] = values;
sendIsolateServiceMessage(sendPort, request);
@@ -82,12 +94,12 @@ class Message {
_completer.complete(value);
}
};
- var keys = options.keys.toList(growable:false);
- var values = options.values.toList(growable:false);
+ var keys = params.keys.toList(growable:false);
+ var values = params.values.toList(growable:false);
var request = new List(5)
..[0] = 0 // Make room for OOB message type.
..[1] = receivePort.sendPort
- ..[2] = path
+ ..[2] = (isOld ? path : method)
..[3] = keys
..[4] = values;
sendRootServiceMessage(request);
@@ -105,7 +117,7 @@ class Message {
'kind': 'RequestError',
'message': error,
'path': path,
- 'options': options
+ 'params': params
}));
}
}
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/service/protocol.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698