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

Side by Side Diff: runtime/observatory/lib/src/elements/metrics.dart

Issue 1262003002: Fix exception on first navigation to metrics page (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 metrics; 5 library metrics;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'observatory_element.dart'; 9 import 'observatory_element.dart';
10 import 'package:observatory/app.dart'; 10 import 'package:observatory/app.dart';
11 import 'package:observatory/service.dart'; 11 import 'package:observatory/service.dart';
12 import 'package:polymer/polymer.dart'; 12 import 'package:polymer/polymer.dart';
13 13
14 @CustomTag('metrics-page') 14 @CustomTag('metrics-page')
15 class MetricsPageElement extends ObservatoryElement { 15 class MetricsPageElement extends ObservatoryElement {
16 MetricsPageElement.created() : super.created(); 16 MetricsPageElement.created() : super.created();
17 17
18 @observable MetricsPage page; 18 @observable MetricsPage page;
19 @observable Isolate isolate; 19 @observable Isolate isolate;
20 @observable ServiceMetric selectedMetric; 20 @observable ServiceMetric selectedMetric;
21 21
22 void _autoPickSelectedMetric() { 22 void _autoPickSelectedMetric() {
23 if (selectedMetric != null) { 23 if (selectedMetric != null) {
24 return; 24 return;
25 } 25 }
26 // Attempt to pick the last selected metric. 26 // Attempt to pick the last selected metric.
27 if ((isolate != null) && (page != null) && 27 if ((isolate != null) && (page != null) &&
28 (page.selectedMetricId != null)) { 28 (page.selectedMetricId != null)) {
29 selectedMetric = isolate.dartMetrics[page.selectedMetricId]; 29 selectedMetric = isolate.dartMetrics[page.selectedMetricId];
30 if (selectedMetric == null) { 30 if (selectedMetric != null) {
31 selectedMetric = isolate.nativeMetrics[page.selectedMetricId]; 31 return;
32 } 32 }
33 selectedMetric = isolate.nativeMetrics[page.selectedMetricId];
33 } 34 }
34 if ((selectedMetric == null) && (isolate != null)) { 35 if ((selectedMetric == null) && (isolate != null)) {
35 var values = isolate.dartMetrics.values; 36 var values = isolate.dartMetrics.values.toList();
36 if (values != null) { 37 if ((values != null) && (values.length > 0)) {
37 // Fall back and pick the first isolate metric. 38 // Fall back and pick the first isolate metric.
38 selectedMetric = values.first; 39 selectedMetric = values.first;
39 } 40 }
41 if (selectedMetric != null) {
42 return;
43 }
44 values = isolate.nativeMetrics.values.toList();
45 if ((values != null) && (values.length > 0)) {
46 // Fall back and pick the first isolate metric.
47 selectedMetric = values.first;
48 }
40 } 49 }
41 } 50 }
42 51
43 void attached() { 52 void attached() {
44 _autoPickSelectedMetric(); 53 _autoPickSelectedMetric();
45 } 54 }
46 55
47 void isolateChanged(oldValue) { 56 void isolateChanged(oldValue) {
48 if (isolate != null) { 57 if (isolate != null) {
49 isolate.refreshMetrics().then((_) { 58 isolate.refreshMetrics().then((_) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 _table.addTimeOfDayValue(sample.time, sample.value); 199 _table.addTimeOfDayValue(sample.time, sample.value);
191 } 200 }
192 } 201 }
193 202
194 metricChanged(oldValue) { 203 metricChanged(oldValue) {
195 if (oldValue != metric) { 204 if (oldValue != metric) {
196 _setupInitialDataTable(); 205 _setupInitialDataTable();
197 } 206 }
198 } 207 }
199 } 208 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698