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

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

Issue 1500073003: Load Observatory assets lazily (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | 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 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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698