| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 heap_map_element; | 5 library heap_map_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 import 'observatory_element.dart'; | 10 import 'observatory_element.dart'; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Many browsers will not display a very tall canvas. | 64 // Many browsers will not display a very tall canvas. |
| 65 // TODO(koda): Improve interface for huge heaps. | 65 // TODO(koda): Improve interface for huge heaps. |
| 66 static const _MAX_CANVAS_HEIGHT = 6000; | 66 static const _MAX_CANVAS_HEIGHT = 6000; |
| 67 | 67 |
| 68 @observable String status; | 68 @observable String status; |
| 69 @published ServiceMap fragmentation; | 69 @published ServiceMap fragmentation; |
| 70 | 70 |
| 71 HeapMapElement.created() : super.created() { | 71 HeapMapElement.created() : super.created() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 void enteredView() { | 74 @override |
| 75 super.enteredView(); | 75 void attached() { |
| 76 super.attached(); |
| 76 _fragmentationCanvas = shadowRoot.querySelector("#fragmentation"); | 77 _fragmentationCanvas = shadowRoot.querySelector("#fragmentation"); |
| 77 _fragmentationCanvas.onMouseMove.listen(_handleMouseMove); | 78 _fragmentationCanvas.onMouseMove.listen(_handleMouseMove); |
| 78 _fragmentationCanvas.onMouseDown.listen(_handleClick); | 79 _fragmentationCanvas.onMouseDown.listen(_handleClick); |
| 79 } | 80 } |
| 80 | 81 |
| 81 // Encode color as single integer, to enable using it as a map key. | 82 // Encode color as single integer, to enable using it as a map key. |
| 82 int _packColor(Iterable<int> color) { | 83 int _packColor(Iterable<int> color) { |
| 83 int packed = 0; | 84 int packed = 0; |
| 84 for (var component in color) { | 85 for (var component in color) { |
| 85 packed = packed * 256 + component; | 86 packed = packed * 256 + component; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 216 } |
| 216 fragmentation.isolate.get('heapmap').then((ServiceMap response) { | 217 fragmentation.isolate.get('heapmap').then((ServiceMap response) { |
| 217 assert(response['type'] == 'HeapMap'); | 218 assert(response['type'] == 'HeapMap'); |
| 218 fragmentation = response; | 219 fragmentation = response; |
| 219 }).catchError((e, st) { | 220 }).catchError((e, st) { |
| 220 Logger.root.info('$e $st'); | 221 Logger.root.info('$e $st'); |
| 221 }).whenComplete(done); | 222 }).whenComplete(done); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void fragmentationChanged(oldValue) { | 225 void fragmentationChanged(oldValue) { |
| 225 // Async, in case enteredView has not yet run (observed in JS version). | 226 // Async, in case attached has not yet run (observed in JS version). |
| 226 new Future(() { | 227 new Future(() { |
| 227 _updateFragmentationData(); | 228 _updateFragmentationData(); |
| 228 }); | 229 }); |
| 229 } | 230 } |
| 230 } | 231 } |
| OLD | NEW |