Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: runtime/observatory/lib/src/elements/metrics.dart

Issue 839543002: Revert "Build Observatory with runtime" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/metrics.dart
diff --git a/runtime/observatory/lib/src/elements/metrics.dart b/runtime/observatory/lib/src/elements/metrics.dart
deleted file mode 100644
index d1e4c6671724dc1f5d596a40387c555a1c866d72..0000000000000000000000000000000000000000
--- a/runtime/observatory/lib/src/elements/metrics.dart
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library metrics;
-
-import 'dart:async';
-import 'dart:html';
-import 'observatory_element.dart';
-import 'package:observatory/app.dart';
-import 'package:observatory/service.dart';
-import 'package:polymer/polymer.dart';
-
-@CustomTag('metrics-page')
-class MetricsPageElement extends ObservatoryElement {
- MetricsPageElement.created() : super.created();
-
- @observable MetricsPage page;
- @observable Isolate isolate;
- @observable ServiceMetric selectedMetric;
-
- void _autoPickSelectedMetric() {
- if (selectedMetric != null) {
- return;
- }
- // Attempt to pick the last selected metric.
- if ((isolate != null) && (page != null) &&
- (page.selectedMetricId != null)) {
- selectedMetric = isolate.dartMetrics[page.selectedMetricId];
- if (selectedMetric == null) {
- selectedMetric = isolate.vmMetrics[page.selectedMetricId];
- }
- }
- if ((selectedMetric == null) && (isolate != null)) {
- var values = isolate.dartMetrics.values;
- if (values != null) {
- // Fall back and pick the first isolate metric.
- selectedMetric = values.first;
- }
- }
- }
-
- void attached() {
- _autoPickSelectedMetric();
- }
-
- void isolateChanged(oldValue) {
- if (isolate != null) {
- isolate.refreshMetrics().then((_) {
- _autoPickSelectedMetric();
- });
- }
- }
-
- void refresh(var done) {
- isolate.refreshMetrics().whenComplete(done);
- }
-
- void selectMetric(Event e, var detail, Element target) {
- String id = target.attributes['data-id'];
- selectedMetric = isolate.dartMetrics[id];
- if (selectedMetric == null) {
- // Check VM metrics.
- selectedMetric = isolate.vmMetrics[id];
- }
- if (selectedMetric != null) {
- page.selectedMetricId = id;
- } else {
- page.selectedMetricId = null;
- }
- }
-}
-
-@CustomTag('metric-details')
-class MetricDetailsElement extends ObservatoryElement {
- MetricDetailsElement.created() : super.created();
- @published MetricsPage page;
- @published ServiceMetric metric;
-
- int _findIndex(SelectElement element, int value) {
- if (element == null) {
- return null;
- }
- for (var i = 0; i < element.options.length; i++) {
- var optionElement = element.options[i];
- int optionValue = int.parse(optionElement.value);
- if (optionValue == value) {
- return i;
- }
- }
- return null;
- }
-
- void attached() {
- super.attached();
- _updateSelectedIndexes();
- }
-
- void _updateSelectedIndexes() {
- if (metric == null) {
- return;
- }
- SelectElement refreshRateElement = shadowRoot.querySelector('#refreshrate');
- if (refreshRateElement == null) {
- // Race between shadowRoot setup and events.
- return;
- }
- int period = 0;
- if (metric.poller != null) {
- period = metric.poller.pollPeriod.inMilliseconds;
- }
- var index = _findIndex(refreshRateElement, period);
- assert(index != null);
- refreshRateElement.selectedIndex = index;
- SelectElement bufferSizeElement = shadowRoot.querySelector('#buffersize');
- index = _findIndex(bufferSizeElement, metric.sampleBufferSize);
- assert(index != null);
- bufferSizeElement.selectedIndex = index;
- }
-
- metricChanged(oldValue) {
- _updateSelectedIndexes();
- }
-
- void refreshRateChange(Event e, var detail, Element target) {
- var value = int.parse((target as SelectElement).value);
- if (metric == null) {
- return;
- }
- page.setRefreshPeriod(value, metric);
- }
-
- void sampleBufferSizeChange(Event e, var detail, Element target) {
- var value = int.parse((target as SelectElement).value);
- if (metric == null) {
- return;
- }
- metric.sampleBufferSize = value;
- }
-}
-
-@CustomTag('metrics-graph')
-class MetricsGraphElement extends ObservatoryElement {
- MetricsGraphElement.created() : super.created();
-
- final DataTable _table = new DataTable();
- Chart _chart;
-
- @published ServiceMetric metric;
- @observable Isolate isolate;
-
- void attached() {
- // Redraw once a second.
- pollPeriod = new Duration(seconds: 1);
- super.attached();
- }
-
- void onPoll() {
- draw();
- }
-
- void draw() {
- if (_chart == null) {
- // Construct chart.
- var element = shadowRoot.querySelector('#graph');
- if (element == null) {
- // Bail.
- return;
- }
- _chart = new Chart('LineChart', element);
- }
- if (metric == null) {
- return;
- }
- _update();
- _chart.draw(_table);
- }
-
- void _setupInitialDataTable() {
- _table.clearColumns();
- // Only one metric right now.
- _table.addColumn('timeofday', 'time');
- _table.addColumn('number', metric.name);
- }
-
- void _update() {
- _table.clearRows();
- for (var i = 0; i < metric.samples.length; i++) {
- var sample = metric.samples[i];
- _table.addTimeOfDayValue(sample.time, sample.value);
- }
- }
-
- metricChanged(oldValue) {
- if (oldValue != metric) {
- _setupInitialDataTable();
- }
- }
-}
« no previous file with comments | « runtime/observatory/lib/src/elements/library_view.html ('k') | runtime/observatory/lib/src/elements/metrics.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698