| 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'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 bool _autoStart; | 21 bool _autoStart; |
| 22 | 22 |
| 23 bool _isWindows = false; | 23 bool _isWindows = false; |
| 24 | 24 |
| 25 var _signalWatch; | 25 var _signalWatch; |
| 26 var _signalSubscription; | 26 var _signalSubscription; |
| 27 | 27 |
| 28 // HTTP server. | 28 // HTTP server. |
| 29 Server server; | 29 Server server; |
| 30 Future<Server> serverFuture; | 30 Future<Server> serverFuture; |
| 31 HashMap<String, Asset> assets; | 31 HashMap<String, Asset> _assets; |
| 32 HashMap<String, Asset> get assets { |
| 33 if (_assets == null) { |
| 34 try { |
| 35 _assets = Asset.request(); |
| 36 } catch (e) { |
| 37 print('Could not load Observatory assets: $e'); |
| 38 } |
| 39 } |
| 40 return _assets; |
| 41 } |
| 32 | 42 |
| 33 _onShutdown() { | 43 _onShutdown() { |
| 34 if (server != null) { | 44 if (server != null) { |
| 35 server.close(true).catchError((e, st) { | 45 server.close(true).catchError((e, st) { |
| 36 print("Error in vm-service shutdown: $e\n$st\n"); | 46 print("Error in vm-service shutdown: $e\n$st\n"); |
| 37 }); | 47 }); |
| 38 } | 48 } |
| 39 if (_signalSubscription != null) { | 49 if (_signalSubscription != null) { |
| 40 _signalSubscription.cancel(); | 50 _signalSubscription.cancel(); |
| 41 _signalSubscription = null; | 51 _signalSubscription = null; |
| 42 } | 52 } |
| 43 } | 53 } |
| 44 | 54 |
| 45 _bootServer() { | 55 _bootServer() { |
| 46 try { | |
| 47 assets = Asset.request(); | |
| 48 } catch (e) { | |
| 49 print('Could not load Observatory assets: $e'); | |
| 50 } | |
| 51 // Lazily create service. | 56 // Lazily create service. |
| 52 var service = new VMService(); | 57 var service = new VMService(); |
| 53 service.onShutdown = _onShutdown; | 58 service.onShutdown = _onShutdown; |
| 54 // Lazily create server. | 59 // Lazily create server. |
| 55 server = new Server(service, _ip, _port); | 60 server = new Server(service, _ip, _port); |
| 56 } | 61 } |
| 57 | 62 |
| 58 _clearFuture(_) { | 63 _clearFuture(_) { |
| 59 serverFuture = null; | 64 serverFuture = null; |
| 60 } | 65 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // else { | 106 // else { |
| 102 // var service = new VMService(); | 107 // var service = new VMService(); |
| 103 // service.onShutdown = _onShutdown; | 108 // service.onShutdown = _onShutdown; |
| 104 // } | 109 // } |
| 105 scriptLoadPort.handler = _processLoadRequest; | 110 scriptLoadPort.handler = _processLoadRequest; |
| 106 // Register signal handler after a small delay to avoid stalling main | 111 // Register signal handler after a small delay to avoid stalling main |
| 107 // isolate startup. | 112 // isolate startup. |
| 108 new Timer(_shortDelay, _registerSignalHandler); | 113 new Timer(_shortDelay, _registerSignalHandler); |
| 109 return scriptLoadPort; | 114 return scriptLoadPort; |
| 110 } | 115 } |
| OLD | NEW |