Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 'isolate_element.dart'; | 8 import 'observatory_element.dart'; |
| 9 import 'package:observatory/service.dart'; | |
| 9 | 10 |
| 10 @CustomTag('service-ref') | 11 @CustomTag('service-ref') |
| 11 class ServiceRefElement extends IsolateElement { | 12 class ServiceRefElement extends ObservatoryElement { |
| 12 @published Map ref; | 13 @published ServiceObject ref; |
| 13 @published bool internal = false; | 14 @published bool internal = false; |
| 14 ServiceRefElement.created() : super.created(); | 15 ServiceRefElement.created() : super.created(); |
| 15 | 16 |
| 16 void refChanged(oldValue) { | 17 void refChanged(oldValue) { |
| 17 notifyPropertyChange(#url, "", url); | 18 notifyPropertyChange(#url, "", url); |
| 18 notifyPropertyChange(#name, [], name); | 19 notifyPropertyChange(#name, [], name); |
| 19 notifyPropertyChange(#hoverText, "", hoverText); | 20 notifyPropertyChange(#hoverText, "", hoverText); |
| 20 } | 21 } |
| 21 | 22 |
| 22 String get url { | 23 String get url { |
| 23 if ((isolate == null) || (ref == null)) { | 24 if (ref == null) { |
| 24 return ''; | 25 return 'NULL REF'; |
|
turnidge
2014/03/10 21:03:28
Do these nulls happen a lot? Do they happen at al
Cutch
2014/03/11 03:17:48
Let's discuss this tomorrow.
| |
| 25 } | 26 } |
| 26 return isolate.hashLink(objectId); | 27 return ref.hashLink; |
| 27 } | 28 } |
| 28 | 29 |
| 29 String get objectId => ref == null ? '' : ref['id']; | 30 String get serviceId { |
| 31 if (ref == null) { | |
| 32 return 'NULL REF'; | |
| 33 } | |
| 34 return ref.id; | |
| 35 } | |
| 30 | 36 |
| 31 String get hoverText { | 37 String get hoverText { |
| 32 if (ref == null) { | 38 if (ref == null) { |
| 33 return ''; | 39 return 'NULL REF'; |
| 34 } | 40 } |
| 35 // Return the VM name by default. | 41 return ref.vmName; |
| 36 var name = ref['name']; | |
| 37 return name != null ? name : ''; | |
| 38 } | 42 } |
| 39 | 43 |
| 40 String get name { | 44 String get name { |
| 41 if (ref == null) { | 45 if (ref == null) { |
| 42 return 'NULL REF'; | 46 return 'NULL REF'; |
| 43 } | 47 } |
| 44 String name_key = internal ? 'name' : 'user_name'; | 48 return ref.name; |
| 45 if (ref[name_key] != null) { | |
| 46 return ref[name_key]; | |
| 47 } else if (ref['name'] != null) { | |
| 48 return ref['name']; | |
| 49 } else if (ref['user_name'] != null) { | |
| 50 return ref['user_name']; | |
| 51 } | |
| 52 return ''; | |
| 53 } | 49 } |
| 54 } | 50 } |
| OLD | NEW |