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

Side by Side Diff: sdk/lib/vmservice/message.dart

Issue 2059883003: DevFS initial implementation (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« runtime/vm/json_stream.cc ('K') | « runtime/vm/vm_sources.gypi ('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) 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 dart._vmservice; 5 part of dart._vmservice;
6 6
7 class Message { 7 class Message {
8 final Completer _completer = new Completer.sync(); 8 final Completer _completer = new Completer.sync();
9 bool get completed => _completer.isCompleted; 9 bool get completed => _completer.isCompleted;
10 /// Future of response. 10 /// Future of response.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 _completer.complete(JSON.encode({ 109 _completer.complete(JSON.encode({
110 'type': 'ServiceError', 110 'type': 'ServiceError',
111 'id': '', 111 'id': '',
112 'kind': 'InternalError', 112 'kind': 'InternalError',
113 'message': 'could not send message [${serial}] to isolate', 113 'message': 'could not send message [${serial}] to isolate',
114 })); 114 }));
115 } 115 }
116 return _completer.future; 116 return _completer.future;
117 } 117 }
118 118
119 bool _isFileSystemMethod(String method) {
turnidge 2016/06/10 18:45:34 Maybe _methodNeedsObjectParameters or something...
120 switch (method) {
121 case '_listDevFS':
122 case '_listDevFSFiles':
123 case '_createDevFS':
124 case '_deleteDevFS':
125 case '_writeDevFSFile':
126 case '_writeDevFSFiles':
127 case '_readDevFSFile':
128 return true;
129 default:
130 return false;
131 }
132 }
133
119 Future<String> sendToVM() { 134 Future<String> sendToVM() {
120 final receivePort = new RawReceivePort(); 135 final receivePort = new RawReceivePort();
121 receivePort.handler = (value) { 136 receivePort.handler = (value) {
122 receivePort.close(); 137 receivePort.close();
123 _completer.complete(value); 138 _completer.complete(value);
124 }; 139 };
125 var keys = _makeAllString(params.keys.toList(growable:false)); 140 if (_isFileSystemMethod(method)) {
126 var values = _makeAllString(params.values.toList(growable:false)); 141 // We use a different method invocation path here.
127 var request = new List(6) 142 var keys = params.keys.toList(growable:false);
128 ..[0] = 0 // Make room for OOB message type. 143 var values = params.values.toList(growable:false);
129 ..[1] = receivePort.sendPort 144 var request = new List(6)
130 ..[2] = serial 145 ..[0] = 0 // Make room for OOB message type.
131 ..[3] = method 146 ..[1] = receivePort.sendPort
132 ..[4] = keys 147 ..[2] = serial
133 ..[5] = values; 148 ..[3] = method
134 sendRootServiceMessage(request); 149 ..[4] = keys
135 return _completer.future; 150 ..[5] = values;
151 sendObjectRootServiceMessage(request);
152 return _completer.future;
153 } else {
154 var keys = _makeAllString(params.keys.toList(growable:false));
155 var values = _makeAllString(params.values.toList(growable:false));
156 var request = new List(6)
157 ..[0] = 0 // Make room for OOB message type.
158 ..[1] = receivePort.sendPort
159 ..[2] = serial
160 ..[3] = method
161 ..[4] = keys
162 ..[5] = values;
163 sendRootServiceMessage(request);
164 return _completer.future;
165 }
136 } 166 }
137 167
138 void setResponse(String response) { 168 void setResponse(String response) {
139 _completer.complete(response); 169 _completer.complete(response);
140 } 170 }
141 171
142 void setErrorResponse(int code, String details) { 172 void setErrorResponse(int code, String details) {
143 _completer.complete(encodeRpcError(this, code, 173 _completer.complete(encodeRpcError(this, code,
144 details: '$method: $details')); 174 details: '$method: $details'));
145 } 175 }
146 } 176 }
147 177
148 external bool sendIsolateServiceMessage(SendPort sp, List m); 178 external bool sendIsolateServiceMessage(SendPort sp, List m);
149 external void sendRootServiceMessage(List m); 179 external void sendRootServiceMessage(List m);
180 external void sendObjectRootServiceMessage(List m);
OLDNEW
« runtime/vm/json_stream.cc ('K') | « runtime/vm/vm_sources.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698