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

Side by Side Diff: runtime/bin/vmservice/vmservice_io.dart

Issue 2438613002: Provide an API to dart:developer to control the web server hosting the Service Protocol (Closed)
Patch Set: CHANGELOG.md merge and fatal error Created 4 years, 1 month 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 | « runtime/bin/vmservice/server.dart ('k') | runtime/bin/vmservice_dartium.h » ('j') | 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 library vmservice_io; 5 library vmservice_io;
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:io'; 10 import 'dart:io';
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 var map = {}; 155 var map = {};
156 map['name'] = '/' + filePath.substring(dirPathStr.length); 156 map['name'] = '/' + filePath.substring(dirPathStr.length);
157 map['size'] = stat.size; 157 map['size'] = stat.size;
158 map['modified'] = stat.modified.millisecondsSinceEpoch; 158 map['modified'] = stat.modified.millisecondsSinceEpoch;
159 result.add(map); 159 result.add(map);
160 } 160 }
161 } 161 }
162 return result; 162 return result;
163 } 163 }
164 164
165 Future<Uri> serverInformationCallback() async {
166 _lazyServerBoot();
167 return server.serverAddress;
168 }
169
170 Future<Uri> webServerControlCallback(bool enable) async {
171 _lazyServerBoot();
172 if (server.running == enable) {
173 // No change.
174 return server.serverAddress;
175 }
176
177 if (enable) {
178 await server.startup();
179 return server.serverAddress;
180 } else {
181 await server.shutdown(true);
182 return server.serverAddress;
183 }
184 }
185
165 _clearFuture(_) { 186 _clearFuture(_) {
166 serverFuture = null; 187 serverFuture = null;
167 } 188 }
168 189
169 _onSignal(ProcessSignal signal) { 190 _onSignal(ProcessSignal signal) {
170 if (serverFuture != null) { 191 if (serverFuture != null) {
171 // Still waiting. 192 // Still waiting.
172 return; 193 return;
173 } 194 }
174 _lazyServerBoot(); 195 _lazyServerBoot();
(...skipping 22 matching lines...) Expand all
197 218
198 main() { 219 main() {
199 // Set embedder hooks. 220 // Set embedder hooks.
200 VMServiceEmbedderHooks.cleanup = cleanupCallback; 221 VMServiceEmbedderHooks.cleanup = cleanupCallback;
201 VMServiceEmbedderHooks.createTempDir = createTempDirCallback; 222 VMServiceEmbedderHooks.createTempDir = createTempDirCallback;
202 VMServiceEmbedderHooks.deleteDir = deleteDirCallback; 223 VMServiceEmbedderHooks.deleteDir = deleteDirCallback;
203 VMServiceEmbedderHooks.writeFile = writeFileCallback; 224 VMServiceEmbedderHooks.writeFile = writeFileCallback;
204 VMServiceEmbedderHooks.writeStreamFile = writeStreamFileCallback; 225 VMServiceEmbedderHooks.writeStreamFile = writeStreamFileCallback;
205 VMServiceEmbedderHooks.readFile = readFileCallback; 226 VMServiceEmbedderHooks.readFile = readFileCallback;
206 VMServiceEmbedderHooks.listFiles = listFilesCallback; 227 VMServiceEmbedderHooks.listFiles = listFilesCallback;
228 VMServiceEmbedderHooks.serverInformation = serverInformationCallback;
229 VMServiceEmbedderHooks.webServerControl = webServerControlCallback;
207 // Always instantiate the vmservice object so that the exit message 230 // Always instantiate the vmservice object so that the exit message
208 // can be delivered and waiting loaders can be cancelled. 231 // can be delivered and waiting loaders can be cancelled.
209 var service = new VMService(); 232 var service = new VMService();
210 if (_autoStart) { 233 if (_autoStart) {
211 _lazyServerBoot(); 234 _lazyServerBoot();
212 server.startup(); 235 server.startup();
213 // It's just here to push an event on the event loop so that we invoke the 236 // It's just here to push an event on the event loop so that we invoke the
214 // scheduled microtasks. 237 // scheduled microtasks.
215 Timer.run(() {}); 238 Timer.run(() {});
216 } 239 }
217 scriptLoadPort.handler = _processLoadRequest; 240 scriptLoadPort.handler = _processLoadRequest;
218 // Register signal handler after a small delay to avoid stalling main 241 // Register signal handler after a small delay to avoid stalling main
219 // isolate startup. 242 // isolate startup.
220 _registerSignalHandlerTimer = new Timer(shortDelay, _registerSignalHandler); 243 _registerSignalHandlerTimer = new Timer(shortDelay, _registerSignalHandler);
221 return scriptLoadPort; 244 return scriptLoadPort;
222 } 245 }
223 246
224 _shutdown() native "VMServiceIO_Shutdown"; 247 _shutdown() native "VMServiceIO_Shutdown";
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/bin/vmservice_dartium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698