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

Unified Diff: runtime/bin/vmservice/observatory/lib/src/app/page.dart

Issue 457803002: Initial UI for Metrics in Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/vmservice/observatory/lib/src/app/page.dart
diff --git a/runtime/bin/vmservice/observatory/lib/src/app/page.dart b/runtime/bin/vmservice/observatory/lib/src/app/page.dart
index 14219c68e1ac21d279bb4308a5fffb389c0146d8..f1c110f01335b2cb0372dc3e221521149e58eee8 100644
--- a/runtime/bin/vmservice/observatory/lib/src/app/page.dart
+++ b/runtime/bin/vmservice/observatory/lib/src/app/page.dart
@@ -141,3 +141,66 @@ class VMConnectPage extends Page {
bool canVisit(String url) => url.startsWith('vm-connect/');
}
+
+class MetricsPage extends Page {
+ static RegExp _matcher = new RegExp(r'isolates/.*/metrics');
+ static RegExp _isolateMatcher = new RegExp(r'isolates/.*/');
+
+ // Page state, retained as long as ObservatoryApplication.
+
+ final List<MetricPoller> pollers = new List<MetricPoller>();
+
+ MetricsPage(app) : super(app) {
+ for (var i = 0; i < Metric.pollPeriods.length; i++) {
+ pollers.add(new MetricPoller(Metric.pollPeriods[i]));
+ }
+ }
+
+ void onInstall() {
+ if (element == null) {
+ element = new Element.tag('metrics-page');
+ (element as MetricsPageElement).page = this;
+ }
+ assert(element != null);
+ }
+
+ void setRefreshPeriod(int refreshPeriod, Metric metric) {
+ if (metric.poller != null) {
+ if (metric.poller.period == refreshPeriod) {
+ return;
+ }
+ // Remove from current poller.
+ metric.poller.metrics.remove(metric);
+ metric.poller = null;
+ }
+ if (refreshPeriod == 0) {
+ return;
+ }
+ for (var i = 0; i < pollers.length; i++) {
koda 2014/08/11 16:34:53 Consider using a map keyed by period instead.
Cutch 2014/08/27 22:25:39 Done.
+ var poller = pollers[i];
+ if (poller.period == refreshPeriod) {
+ poller.metrics.add(metric);
+ metric.poller = poller;
+ return;
+ }
+ }
+ throw new FallThroughError();
+ }
+
+ String _isolateId(String url) {
+ // Grab isolate prefix.
+ String isolateId = _isolateMatcher.stringMatch(url);
+ // Remove the trailing slash.
+ return isolateId.substring(0, isolateId.length - 1);
+ }
+
+ void _visit(String url) {
+ assert(element != null);
+ assert(canVisit(url));
+ app.vm.get(_isolateId(url)).then((i) {
+ (element as MetricsPageElement).isolate = i;
+ });
+ }
+
+ bool canVisit(String url) => _matcher.hasMatch(url);
+}

Powered by Google App Engine
This is Rietveld 408576698