Chromium Code Reviews| 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 class IsolateNotFound implements Exception { | |
| 8 String isolateId; | |
| 9 IsolateNotFound(this.isolateId); | |
| 10 String toString() => "IsolateNotFound: $isolateId"; | |
| 11 } | |
| 12 | |
| 7 /// A [Page] controls the user interface of Observatory. At any given time | 13 /// A [Page] controls the user interface of Observatory. At any given time |
| 8 /// one page will be the current page. Pages are registered at startup. | 14 /// one page will be the current page. Pages are registered at startup. |
| 9 /// When the user navigates within the application, each page is asked if it | 15 /// When the user navigates within the application, each page is asked if it |
| 10 /// can handle the current location, the first page to say yes, wins. | 16 /// can handle the current location, the first page to say yes, wins. |
| 11 abstract class Page extends Observable { | 17 abstract class Page extends Observable { |
| 12 final ObservatoryApplication app; | 18 final ObservatoryApplication app; |
| 13 final ObservableMap<String, String> internalArguments = | 19 final ObservableMap<String, String> internalArguments = |
| 14 new ObservableMap<String, String>(); | 20 new ObservableMap<String, String>(); |
| 15 @observable ObservatoryElement element; | 21 @observable ObservatoryElement element; |
| 16 | 22 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 element = new Element.tag(elementTagName); | 58 element = new Element.tag(elementTagName); |
| 53 } | 59 } |
| 54 } | 60 } |
| 55 | 61 |
| 56 void _visit(Uri uri) { | 62 void _visit(Uri uri) { |
| 57 assert(uri != null); | 63 assert(uri != null); |
| 58 assert(canVisit(uri)); | 64 assert(canVisit(uri)); |
| 59 } | 65 } |
| 60 | 66 |
| 61 Future<Isolate> getIsolate(Uri uri) { | 67 Future<Isolate> getIsolate(Uri uri) { |
| 62 return app.vm.getIsolate(uri.queryParameters['isolateId']) | 68 var isolateId = uri.queryParameters['isolateId']; |
| 63 .catchError((e, stack) { | 69 return app.vm.getIsolate(isolateId).then((isolate) { |
|
rmacnak
2015/04/23 18:32:19
Probably push this into the service library.
turnidge
2015/05/01 17:23:55
I'm working on this currently in another CL.
| |
| 64 Logger.root.severe('$path visit error: $e\n$stack'); | 70 if (isolate == null) { |
| 65 return e; | 71 throw new IsolateNotFound(isolateId); |
| 66 }); | 72 } |
| 73 return isolate; | |
| 74 }); | |
| 67 } | 75 } |
| 68 | 76 |
| 69 bool canVisit(Uri uri) => uri.path == path; | 77 bool canVisit(Uri uri) => uri.path == path; |
| 70 } | 78 } |
| 71 | 79 |
| 72 /// Error page for unrecognized paths. | 80 /// Error page for unrecognized paths. |
| 73 class ErrorPage extends Page { | 81 class ErrorPage extends Page { |
| 74 ErrorPage(app) : super(app); | 82 ErrorPage(app) : super(app); |
| 75 | 83 |
| 76 void onInstall() { | 84 void onInstall() { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 element = new Element.tag('vm-connect'); | 293 element = new Element.tag('vm-connect'); |
| 286 } | 294 } |
| 287 assert(element != null); | 295 assert(element != null); |
| 288 } | 296 } |
| 289 | 297 |
| 290 void _visit(Uri uri) { | 298 void _visit(Uri uri) { |
| 291 assert(element != null); | 299 assert(element != null); |
| 292 assert(canVisit(uri)); | 300 assert(canVisit(uri)); |
| 293 } | 301 } |
| 294 | 302 |
| 295 // TODO(turnidge): Update this to not have the trailing slash. | 303 bool canVisit(Uri uri) => uri.path.startsWith('vm-connect'); |
| 296 bool canVisit(Uri uri) => uri.path.startsWith('vm-connect/'); | 304 } |
| 305 | |
| 306 class IsolateReconnectPage extends Page { | |
| 307 IsolateReconnectPage(app) : super(app); | |
| 308 | |
| 309 void onInstall() { | |
| 310 if (element == null) { | |
| 311 element = new Element.tag('isolate-reconnect'); | |
| 312 } | |
| 313 assert(element != null); | |
| 314 } | |
| 315 | |
| 316 void _visit(Uri uri) { | |
| 317 app.vm.reload(); | |
| 318 assert(element != null); | |
| 319 assert(canVisit(uri)); | |
| 320 } | |
| 321 | |
| 322 bool canVisit(Uri uri) => uri.path.startsWith('isolate-reconnect'); | |
| 297 } | 323 } |
| 298 | 324 |
| 299 class MetricsPage extends Page { | 325 class MetricsPage extends Page { |
| 300 // Page state, retained as long as ObservatoryApplication. | 326 // Page state, retained as long as ObservatoryApplication. |
| 301 String selectedMetricId; | 327 String selectedMetricId; |
| 302 | 328 |
| 303 final Map<int, MetricPoller> pollers = new Map<int, MetricPoller>(); | 329 final Map<int, MetricPoller> pollers = new Map<int, MetricPoller>(); |
| 304 | 330 |
| 305 // 8 seconds, 4 seconds, 2 seconds, 1 second, and one hundred milliseconds. | 331 // 8 seconds, 4 seconds, 2 seconds, 1 second, and one hundred milliseconds. |
| 306 static final List<int> POLL_PERIODS = [8000, | 332 static final List<int> POLL_PERIODS = [8000, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 void _visit(Uri uri) { | 373 void _visit(Uri uri) { |
| 348 assert(element != null); | 374 assert(element != null); |
| 349 assert(canVisit(uri)); | 375 assert(canVisit(uri)); |
| 350 app.vm.getIsolate(uri.queryParameters['isolateId']).then((i) { | 376 app.vm.getIsolate(uri.queryParameters['isolateId']).then((i) { |
| 351 (element as MetricsPageElement).isolate = i; | 377 (element as MetricsPageElement).isolate = i; |
| 352 }); | 378 }); |
| 353 } | 379 } |
| 354 | 380 |
| 355 bool canVisit(Uri uri) => uri.path == 'metrics'; | 381 bool canVisit(Uri uri) => uri.path == 'metrics'; |
| 356 } | 382 } |
| OLD | NEW |