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

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

Issue 2345023003: Use dartfmt on Observatory code (Closed)
Patch Set: merge Created 4 years, 3 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
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 class TargetChangeEvent implements M.TargetChangeEvent { 7 class TargetChangeEvent implements M.TargetChangeEvent {
8 final TargetRepository repository; 8 final TargetRepository repository;
9 final bool disconnected; 9 final bool disconnected;
10 TargetChangeEvent(this.repository, [this.disconnected = false]); 10 TargetChangeEvent(this.repository, [this.disconnected = false]);
11 } 11 }
12 12
13 class TargetRepository implements M.TargetRepository { 13 class TargetRepository implements M.TargetRepository {
14
15 static const _historyKey = 'history'; 14 static const _historyKey = 'history';
16 15
17 final StreamController<TargetChangeEvent> _onChange; 16 final StreamController<TargetChangeEvent> _onChange;
18 final Stream<TargetChangeEvent> onChange; 17 final Stream<TargetChangeEvent> onChange;
19 final SettingsRepository _settings = new SettingsRepository('targetManager'); 18 final SettingsRepository _settings = new SettingsRepository('targetManager');
20 19
21 final List<SC.WebSocketVMTarget> _list = <SC.WebSocketVMTarget>[]; 20 final List<SC.WebSocketVMTarget> _list = <SC.WebSocketVMTarget>[];
22 SC.WebSocketVMTarget current; 21 SC.WebSocketVMTarget current;
23 22
24 factory TargetRepository() { 23 factory TargetRepository() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 74
76 /// Read settings from data store. 75 /// Read settings from data store.
77 void _restore() { 76 void _restore() {
78 _list.clear(); 77 _list.clear();
79 var loaded = _settings.get(_historyKey); 78 var loaded = _settings.get(_historyKey);
80 if (loaded == null) { 79 if (loaded == null) {
81 return; 80 return;
82 } 81 }
83 _list.addAll(loaded.map((i) => new SC.WebSocketVMTarget.fromMap(i))); 82 _list.addAll(loaded.map((i) => new SC.WebSocketVMTarget.fromMap(i)));
84 _list.sort((SC.WebSocketVMTarget a, SC.WebSocketVMTarget b) { 83 _list.sort((SC.WebSocketVMTarget a, SC.WebSocketVMTarget b) {
85 return b.lastConnectionTime.compareTo(a.lastConnectionTime); 84 return b.lastConnectionTime.compareTo(a.lastConnectionTime);
86 }); 85 });
87 } 86 }
88 87
89 /// After making a change, update settings. 88 /// After making a change, update settings.
90 void _store() { 89 void _store() {
91 _settings.set(_historyKey, _list); 90 _settings.set(_historyKey, _list);
92 } 91 }
93 92
94 /// Find by networkAddress. 93 /// Find by networkAddress.
95 SC.WebSocketVMTarget _find(String networkAddress) { 94 SC.WebSocketVMTarget _find(String networkAddress) {
96 for (SC.WebSocketVMTarget item in _list) { 95 for (SC.WebSocketVMTarget item in _list) {
97 if (item.networkAddress == networkAddress) { 96 if (item.networkAddress == networkAddress) {
98 return item; 97 return item;
99 } 98 }
100 } 99 }
101 return null; 100 return null;
102 } 101 }
103 102
104 static String _networkAddressOfDefaultTarget() { 103 static String _networkAddressOfDefaultTarget() {
105 if (Utils.runningInJavaScript()) { 104 if (Utils.runningInJavaScript()) {
106 // We are running as JavaScript, use the same host that Observatory has 105 // We are running as JavaScript, use the same host that Observatory has
107 // been loaded from. 106 // been loaded from.
108 return 'ws://${window.location.host}/ws'; 107 return 'ws://${window.location.host}/ws';
109 } else { 108 } else {
110 // Otherwise, assume we are running from Dart Editor and want to connect 109 // Otherwise, assume we are running from Dart Editor and want to connect
111 // to the default host. 110 // to the default host.
112 return 'ws://localhost:8181/ws'; 111 return 'ws://localhost:8181/ws';
113 } 112 }
114 } 113 }
115 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698