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 instance_ref_element; | 5 library instance_ref_element; |
| 6 | 6 |
| 7 import 'package:logging/logging.dart'; | 7 import 'package:logging/logging.dart'; |
| 8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
| 9 import 'package:observatory/service.dart'; | |
| 9 import 'service_ref.dart'; | 10 import 'service_ref.dart'; |
| 10 | 11 |
| 11 @CustomTag('instance-ref') | 12 @CustomTag('instance-ref') |
| 12 class InstanceRefElement extends ServiceRefElement { | 13 class InstanceRefElement extends ServiceRefElement { |
| 13 InstanceRefElement.created() : super.created(); | 14 InstanceRefElement.created() : super.created(); |
| 14 | 15 |
| 15 String get name { | |
| 16 if (ref == null) { | |
| 17 return super.name; | |
| 18 } | |
| 19 return ref['preview']; | |
| 20 } | |
| 21 | |
| 22 String get hoverText { | 16 String get hoverText { |
| 23 if (ref != null) { | 17 if (ref != null) { |
| 24 if (ref['type'] == '@Null') { | 18 if (ref.serviceType == 'Null') { |
| 25 if (ref['id'] == 'objects/optimized-out') { | 19 if (ref.id == 'objects/optimized-out') { |
| 26 return 'This object is no longer needed and has been removed by the op timizing compiler.'; | 20 return 'This object is no longer needed and has been removed by the op timizing compiler.'; |
| 27 } else if (ref['id'] == 'objects/collected') { | 21 } else if (ref.id == 'objects/collected') { |
| 28 return 'This object has been reclaimed by the garbage collector.'; | 22 return 'This object has been reclaimed by the garbage collector.'; |
| 29 } else if (ref['id'] == 'objects/expired') { | 23 } else if (ref.id == 'objects/expired') { |
| 30 return 'The handle to this object has expired. Consider refreshing th e page.'; | 24 return 'The handle to this object has expired. Consider refreshing th e page.'; |
| 31 } else if (ref['id'] == 'objects/not-initialized') { | 25 } else if (ref.id == 'objects/not-initialized') { |
| 32 return 'This object will be initialized once it is accessed by the pro gram.'; | 26 return 'This object will be initialized once it is accessed by the pro gram.'; |
| 33 } else if (ref['id'] == 'objects/being-initialized') { | 27 } else if (ref.id == 'objects/being-initialized') { |
| 34 return 'This object is currently being initialized.'; | 28 return 'This object is currently being initialized.'; |
| 35 } | 29 } |
| 36 } | 30 } |
| 37 } | 31 } |
| 38 return ''; | 32 return super.hoverText; |
| 39 } | 33 } |
| 40 | 34 |
| 41 // TODO(turnidge): This is here to workaround vm/dart2js differences. | 35 // TODO(turnidge): This is here to workaround vm/dart2js differences. |
| 42 dynamic expander() { | 36 dynamic expander() { |
| 43 return expandEvent; | 37 return expandEvent; |
| 44 } | 38 } |
| 45 | 39 |
| 46 void expandEvent(bool expand, var done) { | 40 void expandEvent(bool expand, var done) { |
| 47 print("Calling expandEvent"); | 41 assert(ref is ServiceMap); |
| 42 ServiceMap refMap = ref; | |
| 48 if (expand) { | 43 if (expand) { |
|
turnidge
2014/03/10 21:03:28
Would it work to replace this with ref.refresh(don
Cutch
2014/03/11 03:17:48
Yep.
| |
| 49 isolate.getMap(objectId).then((map) { | 44 ref.isolate.fetch(ref.id).then((ServiceMap map) { |
| 50 if (map['type'] == 'Null') { | 45 if (map.serviceType == 'Null') { |
| 51 // The object is no longer available. For example, the | |
| 52 // object id may have expired or the object may have been | |
| 53 // collected by the gc. | |
| 54 map['type'] = '@Null'; | |
| 55 ref = map; | 46 ref = map; |
| 47 ref.name = map['preview']; | |
| 48 ref.vmName = map['preview']; | |
| 56 } else { | 49 } else { |
| 57 ref['fields'] = map['fields']; | 50 refMap['fields'] = map['fields']; |
| 58 ref['elements'] = map['elements']; | 51 refMap['elements'] = map['elements']; |
| 59 ref['length'] = map['length']; | 52 refMap['length'] = map['length']; |
| 60 } | 53 } |
| 61 ref['fields'] = map['fields']; | 54 refMap['fields'] = map['fields']; |
| 62 ref['elements'] = map['elements']; | 55 refMap['elements'] = map['elements']; |
| 63 ref['length'] = map['length']; | 56 refMap['length'] = map['length']; |
| 64 }).catchError((e, trace) { | 57 }).catchError((e, trace) { |
| 65 Logger.root.severe('Error while expanding instance-ref: $e\n$trace'); | 58 Logger.root.severe('Error while expanding instance-ref: $e\n$trace'); |
| 66 }).whenComplete(done); | 59 }).whenComplete(done); |
| 67 } else { | 60 } else { |
| 68 ref['fields'] = null; | 61 refMap['fields'] = null; |
| 69 ref['elements'] = null; | 62 refMap['elements'] = null; |
| 70 done(); | 63 done(); |
| 71 } | 64 } |
| 72 } | 65 } |
| 73 } | 66 } |
| OLD | NEW |