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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory/isolate_manager.dart

Issue 135843006: Improve Code object support in service and observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 part of observatory; 5 part of observatory;
6 6
7 /// Collection of isolates which are running in the VM. Updated 7 /// Collection of isolates which are running in the VM. Updated
8 class IsolateManager extends Observable { 8 class IsolateManager extends Observable {
9 ObservatoryApplication _application; 9 ObservatoryApplication _application;
10 ObservatoryApplication get application => _application; 10 ObservatoryApplication get application => _application;
11 11
12 @observable final Map<String, Isolate> isolates = 12 @observable final Map<String, Isolate> isolates =
13 toObservable(new Map<String, Isolate>()); 13 toObservable(new Map<String, Isolate>());
14 14
15 static bool _foundIsolateInMembers(int id, List<Map> members) { 15 static bool _foundIsolateInMembers(String id, List<Map> members) {
16 return members.any((E) => E['id'] == id); 16 return members.any((E) => E['id'] == id);
17 } 17 }
18 18
19 void _responseInterceptor() { 19 void _responseInterceptor() {
20 _application.requestManager.responses.forEach((response) { 20 _application.requestManager.responses.forEach((response) {
21 if (response['type'] == 'IsolateList') { 21 if (response['type'] == 'IsolateList') {
22 _updateIsolates(response['members']); 22 _updateIsolates(response['members']);
23 } 23 }
24 }); 24 });
25 } 25 }
26 26
27 Isolate getIsolate(String id) { 27 Isolate getIsolate(String id) {
28 Isolate isolate = isolates[id]; 28 Isolate isolate = isolates[id];
29 if (isolate == null) {
30 isolate = new Isolate(id, '');
31 isolates[id] = isolate;
32 }
33 return isolate; 29 return isolate;
34 } 30 }
35 31
36 void _updateIsolates(List<Map> members) { 32 void _updateIsolates(List<Map> members) {
37 // Find dead isolates. 33 // Find dead isolates.
38 var deadIsolates = []; 34 var deadIsolates = [];
39 isolates.forEach((k, v) { 35 isolates.forEach((k, v) {
40 if (!_foundIsolateInMembers(k, members)) { 36 if (!_foundIsolateInMembers(k, members)) {
41 deadIsolates.add(k); 37 deadIsolates.add(k);
42 } 38 }
43 }); 39 });
44 // Remove them. 40 // Remove them.
45 deadIsolates.forEach((k) { 41 deadIsolates.forEach((k) {
46 isolates.remove(k); 42 isolates.remove(k);
47 }); 43 });
48 // Add new isolates. 44 // Add new isolates.
49 members.forEach((k) { 45 members.forEach((k) {
50 var id = k['id']; 46 var id = k['id'];
51 var name = k['name']; 47 var name = k['name'];
52 if (isolates[id] == null) { 48 if (isolates[id] == null) {
53 var isolate = new Isolate(id, name); 49 var isolate = new Isolate(id, name);
54 isolates[id] = isolate; 50 isolates[id] = isolate;
55 } else { 51 } else {
56 isolates[id].name = name; 52 isolates[id].name = name;
57 } 53 }
58 }); 54 });
59 } 55 }
60 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698