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

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

Issue 184233007: Refactor Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 part of app;
6
7 @reflectable
turnidge 2014/03/05 21:02:47 Needed? Here are below.
Cutch 2014/03/05 21:54:23 Done.
8 /// A [ServiceObject] is an object known to the VM service and is tied
9 /// to an owning [Isolate].
10 abstract class ServiceObject extends Observable {
11 /// Owning isolate.
12 final Isolate isolate;
13 /// The complete service url of this object.
14 String get link => isolate.relativeLink(_id);
15 String _id;
16 /// The id of this object.
17 String get id => _id;
18 String _serviceType;
19 /// The service type of this object.
20 String get serviceType => _serviceType;
21
22 /// Refresh [this]. Returns a future which completes to [this].
23 Future refresh();
24
25 ServiceObject(this.isolate, this._id, this._serviceType);
26 }
27
28 @reflectable
29 /// A [ServiceObject] which implements [Map].
30 class ServiceMap extends ServiceObject implements Map {
31 final Map _map = new ObservableMap();
32
33 ServiceMap(Isolate isolate, String id, String serviceType) :
34 super(isolate, id, serviceType) {
35 }
36
37 ServiceMap.fromMap(Isolate isolate, Map m) :
38 super(isolate, m['id'], m['type']) {
39 _fill(m);
40 }
41
42 Future refresh() {
43 isolate.getMap(_id).then(_fill);
44 return new Future.value(this);
45 }
46
47 void _fill(Map m) {
48 _map.clear();
49 _map.addAll(m);
50 // TODO(johnmccutchan): Recursively promote all contains Maps to
51 // ServiceMaps?
turnidge 2014/03/05 21:02:47 Maybe so?
Cutch 2014/03/05 21:54:23 Elaborated on the comment.
52 }
53
54 // Implement Map by forwarding methods to _map.
55 void addAll(Map other) => _map.addAll(other);
56 void clear() => _map.clear();
57 bool containsValue(v) => _map.containsValue(v);
58 bool containsKey(k) => _map.containsKey(k);
59 void forEach(Function f) => _map.forEach(f);
60 putIfAbsent(key, Function ifAbsent) => _map.putIfAbsent(key, ifAbsent);
61 void remove(key) => _map.remove(key);
62 operator [](k) => _map[k];
63 operator []=(k, v) => _map[k] = v;
64 bool get isEmpty => _map.isEmpty;
65 bool get isNotEmpty => _map.isNotEmpty;
66 Iterable get keys => _map.keys;
67 Iterable get values => _map.values;
68 int get length => _map.length;
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698