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

Unified Diff: runtime/observatory/lib/src/app/application.dart

Issue 2167053002: Converted Observatory nav-notify element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added tests Created 4 years, 5 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/app/application.dart
diff --git a/runtime/observatory/lib/src/app/application.dart b/runtime/observatory/lib/src/app/application.dart
index f2096252ec2ba359dd825096b315cbc485303990..af7d0694e4d78d4ea78d346eb61713bf4cf04904 100644
--- a/runtime/observatory/lib/src/app/application.dart
+++ b/runtime/observatory/lib/src/app/application.dart
@@ -4,20 +4,12 @@
part of app;
-class Notification {
- Notification.fromEvent(this.event);
- Notification.fromException(this.exception, this.stacktrace);
-
- ServiceEvent event;
- var exception;
- var stacktrace;
-}
-
/// The observatory application. Instances of this are created and owned
/// by the observatory_application custom element.
class ObservatoryApplication extends Observable {
static ObservatoryApplication app;
final RenderingQueue queue = new RenderingQueue();
+ final NotificationRepository notifications = new NotificationRepository();
final _pageRegistry = new List<Page>();
LocationManager _locationManager;
LocationManager get locationManager => _locationManager;
@@ -32,7 +24,7 @@ class ObservatoryApplication extends Observable {
}
if (_vm != null) {
// Disconnect from current VM.
- notifications.clear();
+ notifications.deleteAll();
_vm.disconnect();
}
if (vm != null) {
@@ -51,8 +43,8 @@ class ObservatoryApplication extends Observable {
return;
}
notifications.add(
- new Notification.fromEvent(
- new ServiceEvent.connectionClosed(reason)));
+ new EventNotification.fromServiceEvent(
+ new ServiceEvent.connectionClosed(reason)));
});
vm.listenEventStream(VM.kIsolateStream, _onEvent);
@@ -66,8 +58,6 @@ class ObservatoryApplication extends Observable {
TraceViewElement _traceView = null;
@reflectable ServiceObject lastErrorOrException;
- @observable ObservableList<Notification> notifications =
- new ObservableList<Notification>();
void _initOnce() {
assert(app == null);
@@ -79,12 +69,16 @@ class ObservatoryApplication extends Observable {
}
void removePauseEvents(Isolate isolate) {
Cutch 2016/07/22 13:58:43 Should this method be on the NotificationRepositor
cbernaschina 2016/07/22 18:27:24 Done.
- notifications.removeWhere((notification) {
- var event = notification.event;
- return (event != null &&
- event.isolate == isolate &&
- event.isPauseEvent);
- });
+ var remove = notifications.list().where((notification) {
+ var event = notification.event;
+ return notification is M.EventNotification &&
+ notification.event is M.IsolateEvent &&
+ notification.event.isolate == isolate &&
+ M.Event.isPauseEvent(notification.event);
+ }).toList(growable: false);
+ remove.forEach((notification) {
+ notifications.delete(notification);
+ });
}
void _onEvent(ServiceEvent event) {
@@ -103,7 +97,7 @@ class ObservatoryApplication extends Observable {
break;
case ServiceEvent.kIsolateReload:
- notifications.add(new Notification.fromEvent(event));
+ notifications.add(new EventNotification.fromServiceEvent(event));
break;
case ServiceEvent.kIsolateExit:
@@ -117,11 +111,11 @@ class ObservatoryApplication extends Observable {
case ServiceEvent.kPauseInterrupted:
case ServiceEvent.kPauseException:
removePauseEvents(event.isolate);
- notifications.add(new Notification.fromEvent(event));
+ notifications.add(new EventNotification.fromServiceEvent(event));
break;
case ServiceEvent.kInspect:
- notifications.add(new Notification.fromEvent(event));
+ notifications.add(new EventNotification.fromServiceEvent(event));
break;
default:
@@ -221,11 +215,13 @@ class ObservatoryApplication extends Observable {
}
void _removeDisconnectEvents() {
- notifications.removeWhere((notification) {
- var event = notification.event;
- return (event != null &&
- event.kind == ServiceEvent.kConnectionClosed);
- });
+ var remove = notifications.list().where((notification) {
Cutch 2016/07/22 13:58:43 same question.
cbernaschina 2016/07/22 18:27:24 Done.
+ return notification is EventNotification &&
+ notification.event is M.ConnectionClosedEvent;
+ }).toList(growable: false);
+ remove.forEach((notification){
+ notifications.delete(notification);
+ });
}
loadCrashDump(Map crashDump) {
@@ -243,7 +239,7 @@ class ObservatoryApplication extends Observable {
// TODO(turnidge): Report this failure via analytics.
Logger.root.warning('Caught exception: ${e}\n${st}');
- notifications.add(new Notification.fromException(e, st));
+ notifications.add(new ExceptionNotification(e, stacktrace: st));
}
// This map keeps track of which curly-blocks have been expanded by the user.

Powered by Google App Engine
This is Rietveld 408576698