| 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 isolate_view_element; | 5 library isolate_view_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'observatory_element.dart'; | 8 import 'observatory_element.dart'; |
| 9 import 'package:observatory/app.dart'; | 9 import 'package:observatory/app.dart'; |
| 10 import 'package:observatory/service.dart'; | 10 import 'package:observatory/service.dart'; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 'maxValue': 100.0, | 72 'maxValue': 100.0, |
| 73 }; | 73 }; |
| 74 } | 74 } |
| 75 _chart.draw(_table); | 75 _chart.draw(_table); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 @CustomTag('isolate-view') | 79 @CustomTag('isolate-view') |
| 80 class IsolateViewElement extends ObservatoryElement { | 80 class IsolateViewElement extends ObservatoryElement { |
| 81 @published Isolate isolate; | 81 @published Isolate isolate; |
| 82 @published Library rootLibrary; |
| 82 Timer _updateTimer; | 83 Timer _updateTimer; |
| 83 TagProfileChart tagProfileChart = new TagProfileChart(); | 84 TagProfileChart tagProfileChart = new TagProfileChart(); |
| 84 IsolateViewElement.created() : super.created(); | 85 IsolateViewElement.created() : super.created(); |
| 85 | 86 |
| 86 Future<ServiceObject> evaluate(String expression) { | 87 Future<ServiceObject> evaluate(String expression) { |
| 87 return isolate.rootLibrary.evaluate(expression); | 88 return isolate.rootLibrary.evaluate(expression); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void _updateTagProfile() { | 91 void _updateTagProfile() { |
| 91 isolate.updateTagProfile().then((tagProfile) { | 92 isolate.updateTagProfile().then((tagProfile) { |
| 92 tagProfileChart.update(tagProfile); | 93 tagProfileChart.update(tagProfile); |
| 93 _drawTagProfileChart(); | 94 _drawTagProfileChart(); |
| 94 if (_updateTimer != null) { | 95 if (_updateTimer != null) { |
| 95 // Start the timer again. | 96 // Start the timer again. |
| 96 _updateTimer = new Timer(new Duration(seconds: 1), _updateTagProfile); | 97 _updateTimer = new Timer(new Duration(seconds: 1), _updateTagProfile); |
| 97 } | 98 } |
| 98 }); | 99 }); |
| 99 } | 100 } |
| 100 | 101 |
| 101 @override | 102 @override |
| 102 void attached() { | 103 void attached() { |
| 103 super.attached(); | 104 super.attached(); |
| 104 // Start a timer to update the isolate summary once a second. | 105 // Start a timer to update the isolate summary once a second. |
| 105 _updateTimer = new Timer(new Duration(seconds: 1), _updateTagProfile); | 106 _updateTimer = new Timer(new Duration(seconds: 1), _updateTagProfile); |
| 106 if (isolate.topFrame != null) { | 107 if (isolate.topFrame != null) { |
| 107 isolate.topFrame.function.load(); | 108 isolate.topFrame.function.load(); |
| 108 } | 109 } |
| 110 isolate.rootLibrary.load().then((lib) => rootLibrary = lib); |
| 109 } | 111 } |
| 110 | 112 |
| 111 @override | 113 @override |
| 112 void detached() { | 114 void detached() { |
| 113 super.detached(); | 115 super.detached(); |
| 114 if (_updateTimer != null) { | 116 if (_updateTimer != null) { |
| 115 _updateTimer.cancel(); | 117 _updateTimer.cancel(); |
| 116 _updateTimer = null; | 118 _updateTimer = null; |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 | 121 |
| 120 void _drawTagProfileChart() { | 122 void _drawTagProfileChart() { |
| 121 var element = shadowRoot.querySelector('#tagProfileChart'); | 123 var element = shadowRoot.querySelector('#tagProfileChart'); |
| 122 if (element != null) { | 124 if (element != null) { |
| 123 tagProfileChart.draw(element); | 125 tagProfileChart.draw(element); |
| 124 } | 126 } |
| 125 } | 127 } |
| 126 | 128 |
| 127 Future refresh() async { | 129 Future refresh() async { |
| 128 await isolate.reload(); | 130 await isolate.reload(); |
| 129 if (isolate.topFrame != null) { | 131 if (isolate.topFrame != null) { |
| 130 await isolate.topFrame.function.load(); | 132 await isolate.topFrame.function.load(); |
| 131 } | 133 } |
| 132 } | 134 } |
| 133 | 135 |
| 134 Future refreshCoverage() { | 136 Future refreshCoverage() { |
| 135 return isolate.refreshCoverage(); | 137 return isolate.refreshCoverage(); |
| 136 } | 138 } |
| 137 } | 139 } |
| OLD | NEW |