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

Side by Side Diff: runtime/observatory/lib/src/repositories/target.dart

Issue 2991183002: Fix Observatory double connection in clean browser (Closed)
Patch Set: Fix variable name Created 3 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 | « 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 part of repositories; 5 part of repositories;
6 6
7 typedef bool IsConnectedVMTargetDelegate(Target); 7 typedef bool IsConnectedVMTargetDelegate(Target);
8 8
9 class TargetChangeEvent implements M.TargetChangeEvent { 9 class TargetChangeEvent implements M.TargetChangeEvent {
10 final TargetRepository repository; 10 final TargetRepository repository;
(...skipping 13 matching lines...) Expand all
24 final IsConnectedVMTargetDelegate _isConnectedVMTarget; 24 final IsConnectedVMTargetDelegate _isConnectedVMTarget;
25 25
26 factory TargetRepository(IsConnectedVMTargetDelegate isConnectedVMTarget) { 26 factory TargetRepository(IsConnectedVMTargetDelegate isConnectedVMTarget) {
27 var controller = new StreamController<TargetChangeEvent>(); 27 var controller = new StreamController<TargetChangeEvent>();
28 var stream = controller.stream.asBroadcastStream(); 28 var stream = controller.stream.asBroadcastStream();
29 return new TargetRepository._(isConnectedVMTarget, controller, stream); 29 return new TargetRepository._(isConnectedVMTarget, controller, stream);
30 } 30 }
31 31
32 TargetRepository._(this._isConnectedVMTarget, this._onChange, this.onChange) { 32 TargetRepository._(this._isConnectedVMTarget, this._onChange, this.onChange) {
33 _restore(); 33 _restore();
34 final defaultAddress = _networkAddressOfDefaultTarget();
35 var defaultTarget = find(defaultAddress);
34 // Add the default address if it doesn't already exist. 36 // Add the default address if it doesn't already exist.
35 if (find(_networkAddressOfDefaultTarget()) == null) { 37 if (defaultTarget == null) {
36 add(_networkAddressOfDefaultTarget()); 38 defaultTarget = new SC.WebSocketVMTarget(defaultAddress);
39 _list.insert(0, defaultTarget);
37 } 40 }
38 // Set the current target to the default target. 41 // Set the current target to the default target.
39 current = find(_networkAddressOfDefaultTarget()); 42 current = defaultTarget;
40 } 43 }
41 44
42 void add(String address) { 45 void add(String address) {
43 if (find(address) != null) { 46 if (find(address) != null) {
44 return; 47 return;
45 } 48 }
46 _list.insert(0, new SC.WebSocketVMTarget(address)); 49 _list.insert(0, new SC.WebSocketVMTarget(address));
47 _onChange.add(new TargetChangeEvent(this)); 50 _onChange.add(new TargetChangeEvent(this));
48 _store(); 51 _store();
49 } 52 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!identical(1, 1.0)) { 110 if (!identical(1, 1.0)) {
108 // Dartium, assume we are developing. 111 // Dartium, assume we are developing.
109 return 'ws://127.0.0.1:8181/ws'; 112 return 'ws://127.0.0.1:8181/ws';
110 } 113 }
111 Uri serverAddress = Uri.parse(window.location.toString()); 114 Uri serverAddress = Uri.parse(window.location.toString());
112 return 'ws://${serverAddress.authority}${serverAddress.path}ws'; 115 return 'ws://${serverAddress.authority}${serverAddress.path}ws';
113 } 116 }
114 117
115 bool isConnectedVMTarget(M.Target target) => _isConnectedVMTarget(target); 118 bool isConnectedVMTarget(M.Target target) => _isConnectedVMTarget(target);
116 } 119 }
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