| 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 part of app; | 5 part of app; |
| 6 | 6 |
| 7 final _allocationProfileRepository = new AllocationProfileRepository(); | 7 final _allocationProfileRepository = new AllocationProfileRepository(); |
| 8 final _breakpointRepository = new BreakpointRepository(); | 8 final _breakpointRepository = new BreakpointRepository(); |
| 9 final _classSampleProfileRepository = new ClassSampleProfileRepository(); | 9 final _classSampleProfileRepository = new ClassSampleProfileRepository(); |
| 10 final _classRepository = new ClassRepository(); | 10 final _classRepository = new ClassRepository(); |
| 11 final _contextRepository = new ContextRepository(); | 11 final _contextRepository = new ContextRepository(); |
| 12 final _evalRepository = new EvalRepository(); | 12 final _evalRepository = new EvalRepository(); |
| 13 final _fieldRepository = new FieldRepository(); | 13 final _fieldRepository = new FieldRepository(); |
| 14 final _functionRepository = new FunctionRepository(); | 14 final _functionRepository = new FunctionRepository(); |
| 15 final _heapSnapshotRepository = new HeapSnapshotRepository(); | 15 final _heapSnapshotRepository = new HeapSnapshotRepository(); |
| 16 final _icdataRepository = new ICDataRepository(); | 16 final _icdataRepository = new ICDataRepository(); |
| 17 final _inboundReferencesRepository = new InboundReferencesRepository(); | 17 final _inboundReferencesRepository = new InboundReferencesRepository(); |
| 18 final _instanceRepository = new InstanceRepository(); | 18 final _instanceRepository = new InstanceRepository(); |
| 19 final _isolateRepository = new IsolateRepository(); | 19 final _isolateRepository = new IsolateRepository(); |
| 20 final _isolateSampleProfileRepository = new IsolateSampleProfileRepository(); | 20 final _isolateSampleProfileRepository = new IsolateSampleProfileRepository(); |
| 21 final _libraryRepository = new LibraryRepository(); | 21 final _libraryRepository = new LibraryRepository(); |
| 22 final _megamorphicCacheRepository = new MegamorphicCacheRepository(); | 22 final _megamorphicCacheRepository = new MegamorphicCacheRepository(); |
| 23 final _metricRepository = new MetricRepository(); |
| 23 final _objectRepository = new ObjectRepository(); | 24 final _objectRepository = new ObjectRepository(); |
| 24 final _objectPoolRepository = new ObjectPoolRepository(); | 25 final _objectPoolRepository = new ObjectPoolRepository(); |
| 25 final _objectstoreRepository = new ObjectStoreRepository(); | 26 final _objectstoreRepository = new ObjectStoreRepository(); |
| 26 final _persistentHandlesRepository = new PersistentHandlesRepository(); | 27 final _persistentHandlesRepository = new PersistentHandlesRepository(); |
| 27 final _portsRepository = new PortsRepository(); | 28 final _portsRepository = new PortsRepository(); |
| 28 final _scriptRepository = new ScriptRepository(); | 29 final _scriptRepository = new ScriptRepository(); |
| 29 final _stronglyReachangleInstancesRepository = | 30 final _stronglyReachangleInstancesRepository = |
| 30 new StronglyReachableInstancesRepository(); | 31 new StronglyReachableInstancesRepository(); |
| 31 final _topRetainingInstancesRepository = new TopRetainingInstancesRepository(); | 32 final _topRetainingInstancesRepository = new TopRetainingInstancesRepository(); |
| 32 final _typeArgumentsRepository = new TypeArgumentsRepository(); | 33 final _typeArgumentsRepository = new TypeArgumentsRepository(); |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 }); | 638 }); |
| 638 } | 639 } |
| 639 | 640 |
| 640 void onInstall() { | 641 void onInstall() { |
| 641 if (element == null) { | 642 if (element == null) { |
| 642 element = container; | 643 element = container; |
| 643 } | 644 } |
| 644 } | 645 } |
| 645 } | 646 } |
| 646 | 647 |
| 647 | |
| 648 class LoggingPage extends SimplePage { | 648 class LoggingPage extends SimplePage { |
| 649 LoggingPage(app) : super('logging', 'logging-page', app); | 649 LoggingPage(app) : super('logging', 'logging-page', app); |
| 650 | 650 |
| 651 void _visit(Uri uri) { | 651 void _visit(Uri uri) { |
| 652 super._visit(uri); | 652 super._visit(uri); |
| 653 getIsolate(uri).then((isolate) { | 653 getIsolate(uri).then((isolate) { |
| 654 if (element != null) { | 654 if (element != null) { |
| 655 /// Update the page. | 655 /// Update the page. |
| 656 LoggingPageElement page = element; | 656 LoggingPageElement page = element; |
| 657 page.isolate = isolate; | 657 page.isolate = isolate; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 uri.queryParameters['isolateId'], | 718 uri.queryParameters['isolateId'], |
| 719 Uri.parse(uri.queryParameters['originalUri'])) | 719 Uri.parse(uri.queryParameters['originalUri'])) |
| 720 ]; | 720 ]; |
| 721 assert(element != null); | 721 assert(element != null); |
| 722 assert(canVisit(uri)); | 722 assert(canVisit(uri)); |
| 723 } | 723 } |
| 724 | 724 |
| 725 bool canVisit(Uri uri) => uri.path == 'isolate-reconnect'; | 725 bool canVisit(Uri uri) => uri.path == 'isolate-reconnect'; |
| 726 } | 726 } |
| 727 | 727 |
| 728 class MetricsPage extends Page { | 728 class MetricsPage extends MatchingPage { |
| 729 // Page state, retained as long as ObservatoryApplication. | 729 MetricsPage(app) : super('metrics', app); |
| 730 String selectedMetricId; | |
| 731 | 730 |
| 732 final Map<int, MetricPoller> pollers = new Map<int, MetricPoller>(); | 731 final DivElement container = new DivElement(); |
| 733 | 732 |
| 734 // 8 seconds, 4 seconds, 2 seconds, 1 second, and one hundred milliseconds. | 733 Isolate lastIsolate; |
| 735 static final List<int> POLL_PERIODS = [8000, | |
| 736 4000, | |
| 737 2000, | |
| 738 1000, | |
| 739 100]; | |
| 740 | 734 |
| 741 MetricsPage(app) : super(app) { | 735 void _visit(Uri uri) { |
| 742 for (var i = 0; i < POLL_PERIODS.length; i++) { | 736 super._visit(uri); |
| 743 pollers[POLL_PERIODS[i]] = new MetricPoller(POLL_PERIODS[i]); | 737 getIsolate(uri).then((isolate) async { |
| 744 } | 738 lastIsolate = isolate; |
| 739 container.children = const []; |
| 740 await _metricRepository.startSampling(isolate); |
| 741 container.children = [ |
| 742 new MetricsPageElement(isolate.vm, isolate, app.events, |
| 743 app.notifications, _metricRepository, |
| 744 queue: app.queue) |
| 745 ]; |
| 746 }); |
| 745 } | 747 } |
| 746 | 748 |
| 747 void onInstall() { | 749 void onInstall() { |
| 748 if (element == null) { | 750 if (element == null) { |
| 749 element = new Element.tag('metrics-page'); | 751 element = container; |
| 750 (element as MetricsPageElement).page = this; | |
| 751 } | 752 } |
| 752 assert(element != null); | |
| 753 } | 753 } |
| 754 | 754 |
| 755 void setRefreshPeriod(int refreshPeriod, ServiceMetric metric) { | 755 @override |
| 756 if (metric.poller != null) { | 756 void onUninstall() { |
| 757 if (metric.poller.pollPeriod.inMilliseconds == refreshPeriod) { | 757 _metricRepository.stopSampling(lastIsolate); |
| 758 return; | |
| 759 } | |
| 760 // Remove from current poller. | |
| 761 metric.poller.metrics.remove(metric); | |
| 762 metric.poller = null; | |
| 763 } | |
| 764 if (refreshPeriod == 0) { | |
| 765 return; | |
| 766 } | |
| 767 var poller = pollers[refreshPeriod]; | |
| 768 if (poller != null) { | |
| 769 poller.metrics.add(metric); | |
| 770 metric.poller = poller; | |
| 771 return; | |
| 772 } | |
| 773 throw new FallThroughError(); | |
| 774 } | 758 } |
| 775 | |
| 776 void _visit(Uri uri) { | |
| 777 assert(element != null); | |
| 778 assert(canVisit(uri)); | |
| 779 app.vm.getIsolate(uri.queryParameters['isolateId']).then((i) { | |
| 780 (element as MetricsPageElement).isolate = i; | |
| 781 }); | |
| 782 } | |
| 783 | |
| 784 bool canVisit(Uri uri) => uri.path == 'metrics'; | |
| 785 } | 759 } |
| 786 | 760 |
| 787 class TimelinePage extends Page { | 761 class TimelinePage extends Page { |
| 788 TimelinePage(app) : super(app); | 762 TimelinePage(app) : super(app); |
| 789 | 763 |
| 790 void onInstall() { | 764 void onInstall() { |
| 791 if (element == null) { | 765 if (element == null) { |
| 792 element = new Element.tag('timeline-page'); | 766 element = new Element.tag('timeline-page'); |
| 793 } | 767 } |
| 794 assert(element != null); | 768 assert(element != null); |
| 795 } | 769 } |
| 796 | 770 |
| 797 void _visit(Uri uri) { | 771 void _visit(Uri uri) { |
| 798 assert(element != null); | 772 assert(element != null); |
| 799 assert(canVisit(uri)); | 773 assert(canVisit(uri)); |
| 800 } | 774 } |
| 801 | 775 |
| 802 bool canVisit(Uri uri) => uri.path == 'timeline'; | 776 bool canVisit(Uri uri) => uri.path == 'timeline'; |
| 803 } | 777 } |
| OLD | NEW |