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

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

Issue 2225583002: Support devFS writes via HTTP PUT (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rmacnak review Created 4 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 | « sdk/lib/vmservice/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 library dart._vmservice; 5 library dart._vmservice;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 /// Called to create a temporary directory 110 /// Called to create a temporary directory
111 typedef Future<Uri> CreateTempDirCallback(String base); 111 typedef Future<Uri> CreateTempDirCallback(String base);
112 112
113 /// Called to delete a directory 113 /// Called to delete a directory
114 typedef Future DeleteDirCallback(Uri path); 114 typedef Future DeleteDirCallback(Uri path);
115 115
116 /// Called to write a file. 116 /// Called to write a file.
117 typedef Future WriteFileCallback(Uri path, List<int> bytes); 117 typedef Future WriteFileCallback(Uri path, List<int> bytes);
118 118
119 /// Called to write a stream into a file.
120 typedef Future WriteStreamFileCallback(Uri path, Stream<List<int>> bytes);
121
119 /// Called to read a file. 122 /// Called to read a file.
120 typedef Future<List<int>> ReadFileCallback(Uri path); 123 typedef Future<List<int>> ReadFileCallback(Uri path);
121 124
122 /// Called to list all files under some path. 125 /// Called to list all files under some path.
123 typedef Future<List<Map<String,String>>> ListFilesCallback(Uri path); 126 typedef Future<List<Map<String,String>>> ListFilesCallback(Uri path);
124 127
125 /// Hooks that are setup by the embedder. 128 /// Hooks that are setup by the embedder.
126 class VMServiceEmbedderHooks { 129 class VMServiceEmbedderHooks {
127 static ServerStartCallback serverStart; 130 static ServerStartCallback serverStart;
128 static ServerStopCallback serverStop; 131 static ServerStopCallback serverStop;
129 static CleanupCallback cleanup; 132 static CleanupCallback cleanup;
130 static CreateTempDirCallback createTempDir; 133 static CreateTempDirCallback createTempDir;
131 static DeleteDirCallback deleteDir; 134 static DeleteDirCallback deleteDir;
132 static WriteFileCallback writeFile; 135 static WriteFileCallback writeFile;
136 static WriteStreamFileCallback writeStreamFile;
133 static ReadFileCallback readFile; 137 static ReadFileCallback readFile;
134 static ListFilesCallback listFiles; 138 static ListFilesCallback listFiles;
135 } 139 }
136 140
137 class VMService extends MessageRouter { 141 class VMService extends MessageRouter {
138 static VMService _instance; 142 static VMService _instance;
139 143
140 /// Collection of currently connected clients. 144 /// Collection of currently connected clients.
141 final Set<Client> clients = new Set<Client>(); 145 final Set<Client> clients = new Set<Client>();
142 146
143 /// Collection of currently running isolates. 147 /// Collection of currently running isolates.
144 RunningIsolates runningIsolates = new RunningIsolates(); 148 RunningIsolates runningIsolates = new RunningIsolates();
145 149
146 /// A port used to receive events from the VM. 150 /// A port used to receive events from the VM.
147 final RawReceivePort eventPort; 151 final RawReceivePort eventPort;
148 152
149 final _devfs = new DevFS(); 153 final devfs = new DevFS();
150 154
151 void _addClient(Client client) { 155 void _addClient(Client client) {
152 assert(client.streams.isEmpty); 156 assert(client.streams.isEmpty);
153 clients.add(client); 157 clients.add(client);
154 } 158 }
155 159
156 void _removeClient(Client client) { 160 void _removeClient(Client client) {
157 clients.remove(client); 161 clients.remove(client);
158 for (var streamId in client.streams) { 162 for (var streamId in client.streams) {
159 if (!_isAnyClientSubscribed(streamId)) { 163 if (!_isAnyClientSubscribed(streamId)) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Close receive ports. 203 // Close receive ports.
200 isolateLifecyclePort.close(); 204 isolateLifecyclePort.close();
201 scriptLoadPort.close(); 205 scriptLoadPort.close();
202 206
203 // Create a copy of the set as a list because client.disconnect() will 207 // Create a copy of the set as a list because client.disconnect() will
204 // alter the connected clients set. 208 // alter the connected clients set.
205 var clientsList = clients.toList(); 209 var clientsList = clients.toList();
206 for (var client in clientsList) { 210 for (var client in clientsList) {
207 client.disconnect(); 211 client.disconnect();
208 } 212 }
209 _devfs.cleanup(); 213 devfs.cleanup();
210 if (VMServiceEmbedderHooks.cleanup != null) { 214 if (VMServiceEmbedderHooks.cleanup != null) {
211 await VMServiceEmbedderHooks.cleanup(); 215 await VMServiceEmbedderHooks.cleanup();
212 } 216 }
213 // Notify the VM that we have exited. 217 // Notify the VM that we have exited.
214 _onExit(); 218 _onExit();
215 } 219 }
216 220
217 void messageHandler(message) { 221 void messageHandler(message) {
218 if (message is List) { 222 if (message is List) {
219 if (message.length == 2) { 223 if (message.length == 2) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 398 }
395 if (message.method == 'streamListen') { 399 if (message.method == 'streamListen') {
396 return _streamListen(message); 400 return _streamListen(message);
397 } 401 }
398 if (message.method == 'streamCancel') { 402 if (message.method == 'streamCancel') {
399 return _streamCancel(message); 403 return _streamCancel(message);
400 } 404 }
401 if (message.method == '_spawnUri') { 405 if (message.method == '_spawnUri') {
402 return _spawnUri(message); 406 return _spawnUri(message);
403 } 407 }
404 if (_devfs.shouldHandleMessage(message)) { 408 if (devfs.shouldHandleMessage(message)) {
405 return _devfs.handleMessage(message); 409 return devfs.handleMessage(message);
406 } 410 }
407 if (message.params['isolateId'] != null) { 411 if (message.params['isolateId'] != null) {
408 return runningIsolates.route(message); 412 return runningIsolates.route(message);
409 } 413 }
410 return message.sendToVM(); 414 return message.sendToVM();
411 } 415 }
412 } 416 }
413 417
414 RawReceivePort boot() { 418 RawReceivePort boot() {
415 // Return the port we expect isolate startup and shutdown messages on. 419 // Return the port we expect isolate startup and shutdown messages on.
(...skipping 18 matching lines...) Expand all
434 external bool _vmListenStream(String streamId); 438 external bool _vmListenStream(String streamId);
435 439
436 /// Cancel a subscription to a service stream. 440 /// Cancel a subscription to a service stream.
437 external void _vmCancelStream(String streamId); 441 external void _vmCancelStream(String streamId);
438 442
439 /// Get the bytes to the tar archive. 443 /// Get the bytes to the tar archive.
440 external Uint8List _requestAssets(); 444 external Uint8List _requestAssets();
441 445
442 /// Notify the vm service that an isolate has been spawned via rpc. 446 /// Notify the vm service that an isolate has been spawned via rpc.
443 external void _spawnUriNotify(obj, String token); 447 external void _spawnUriNotify(obj, String token);
OLDNEW
« no previous file with comments | « sdk/lib/vmservice/message.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698