| 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 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'; |
| 11 import 'dart:isolate'; | 11 import 'dart:isolate'; |
| 12 import 'dart:_vmservice'; | 12 import 'dart:_vmservice'; |
| 13 | 13 |
| 14 part 'loader.dart'; | 14 part 'loader.dart'; |
| 15 part 'server.dart'; | 15 part 'server.dart'; |
| 16 | 16 |
| 17 // The TCP ip/port that the HTTP server listens on. | 17 // The TCP ip/port that the HTTP server listens on. |
| 18 int _port; | 18 int _port; |
| 19 String _ip; | 19 String _ip; |
| 20 // Should the HTTP server auto start? | 20 // Should the HTTP server auto start? |
| 21 bool _autoStart; | 21 bool _autoStart; |
| 22 | 22 // Should the HTTP server run in devmode? |
| 23 bool _serverDevMode; |
| 23 bool _isWindows = false; | 24 bool _isWindows = false; |
| 24 var _signalWatch; | 25 var _signalWatch; |
| 25 var _signalSubscription; | 26 var _signalSubscription; |
| 26 | 27 |
| 27 // HTTP server. | 28 // HTTP server. |
| 28 Server server; | 29 Server server; |
| 29 Future<Server> serverFuture; | 30 Future<Server> serverFuture; |
| 30 | 31 |
| 31 _lazyServerBoot() { | 32 _lazyServerBoot() { |
| 32 if (server != null) { | 33 if (server != null) { |
| 33 return; | 34 return; |
| 34 } | 35 } |
| 35 // Lazily create service. | 36 // Lazily create service. |
| 36 var service = new VMService(); | 37 var service = new VMService(); |
| 37 // Lazily create server. | 38 // Lazily create server. |
| 38 server = new Server(service, _ip, _port); | 39 server = new Server(service, _ip, _port, _serverDevMode); |
| 39 } | 40 } |
| 40 | 41 |
| 41 Future cleanupCallback() async { | 42 Future cleanupCallback() async { |
| 42 shutdownLoaders(); | 43 shutdownLoaders(); |
| 43 // Cancel the sigquit subscription. | 44 // Cancel the sigquit subscription. |
| 44 if (_signalSubscription != null) { | 45 if (_signalSubscription != null) { |
| 45 await _signalSubscription.cancel(); | 46 await _signalSubscription.cancel(); |
| 46 _signalSubscription = null; | 47 _signalSubscription = null; |
| 47 } | 48 } |
| 48 if (server != null) { | 49 if (server != null) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 Timer.run(() {}); | 152 Timer.run(() {}); |
| 152 } | 153 } |
| 153 scriptLoadPort.handler = _processLoadRequest; | 154 scriptLoadPort.handler = _processLoadRequest; |
| 154 // Register signal handler after a small delay to avoid stalling main | 155 // Register signal handler after a small delay to avoid stalling main |
| 155 // isolate startup. | 156 // isolate startup. |
| 156 _registerSignalHandlerTimer = new Timer(shortDelay, _registerSignalHandler); | 157 _registerSignalHandlerTimer = new Timer(shortDelay, _registerSignalHandler); |
| 157 return scriptLoadPort; | 158 return scriptLoadPort; |
| 158 } | 159 } |
| 159 | 160 |
| 160 _shutdown() native "VMServiceIO_Shutdown"; | 161 _shutdown() native "VMServiceIO_Shutdown"; |
| OLD | NEW |