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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory_elements/service_ref.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
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 service_ref_element; 5 library service_ref_element;
6 6
7 import 'package:polymer/polymer.dart'; 7 import 'package:polymer/polymer.dart';
8 import 'observatory_element.dart'; 8 import 'isolate_element.dart';
9 9
10 @CustomTag('service-ref') 10 @CustomTag('service-ref')
11 class ServiceRefElement extends ObservatoryElement { 11 class ServiceRefElement extends IsolateElement {
12 @published Map ref; 12 @published Map ref;
13 @published bool internal = false; 13 @published bool internal = false;
14 @published Isolate isolate = null;
15 ServiceRefElement.created() : super.created(); 14 ServiceRefElement.created() : super.created();
16 15
17 void refChanged(oldValue) { 16 void refChanged(oldValue) {
18 notifyPropertyChange(#url, "", url); 17 notifyPropertyChange(#url, "", url);
19 notifyPropertyChange(#name, [], name); 18 notifyPropertyChange(#name, [], name);
20 notifyPropertyChange(#hoverText, "", hoverText); 19 notifyPropertyChange(#hoverText, "", hoverText);
21 } 20 }
22 21
23 String get url { 22 String get url {
24 if (ref != null) { 23 if ((isolate == null) || (ref == null)) {
25 return relativeLink(ref['id']); 24 return '';
26 } 25 }
27 return ''; 26 return isolate.hashLink(objectId);
28 } 27 }
29 28
29 String get objectId => ref['id'];
turnidge 2014/03/05 21:02:47 Should we check for ref == null?
Cutch 2014/03/05 21:54:23 Done.
30
30 String get hoverText { 31 String get hoverText {
31 if (ref == null) { 32 if (ref == null) {
32 return ''; 33 return '';
33 } 34 }
34 // Return the VM name by default. 35 // Return the VM name by default.
35 var name = ref['name']; 36 var name = ref['name'];
36 return name != null ? name : ''; 37 return name != null ? name : '';
37 } 38 }
38 39
39 String get name { 40 String get name {
40 if (ref == null) { 41 if (ref == null) {
41 return 'NULL REF'; 42 return 'NULL REF';
42 } 43 }
43 String name_key = internal ? 'name' : 'user_name'; 44 String name_key = internal ? 'name' : 'user_name';
44 if (ref[name_key] != null) { 45 if (ref[name_key] != null) {
45 return ref[name_key]; 46 return ref[name_key];
46 } else if (ref['name'] != null) { 47 } else if (ref['name'] != null) {
47 return ref['name']; 48 return ref['name'];
48 } else if (ref['user_name'] != null) { 49 } else if (ref['user_name'] != null) {
49 return ref['user_name']; 50 return ref['user_name'];
50 } 51 }
51 return ''; 52 return '';
52 } 53 }
53
54 void isolateChanged(oldValue) {
55 notifyPropertyChange(#relativeLink, 0, 1);
56 }
57
58 @observable
59 String relativeLink(String link) {
60 if (app == null) {
61 return '';
62 } else if (isolate == null) {
63 return app.locationManager.currentIsolateRelativeLink(link);
64 } else {
65 return app.locationManager.relativeLink(isolate.id, link);
66 }
67 }
68 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698