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

Unified Diff: runtime/bin/vmstats/models.dart

Issue 18611003: Remove VM Stats (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « runtime/bin/vmstats/isolate_list.dart ('k') | runtime/bin/vmstats/packages/browser/dart.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmstats/models.dart
diff --git a/runtime/bin/vmstats/models.dart b/runtime/bin/vmstats/models.dart
deleted file mode 100644
index 965f4cdba51106395173aee89664a0f89dbafae8..0000000000000000000000000000000000000000
--- a/runtime/bin/vmstats/models.dart
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2013, 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.
-
-part of dart.vmstats;
-
-// Base class of model that reports changes to registered listeners.
-abstract class ObservableModel {
- List<ModelListener> _listeners = [];
-
- void addListener(Function onUpdate, Function onFailure) {
- _listeners.add(new ModelListener(onUpdate, onFailure));
- }
-
- void removeListener(Function onUpdate) {
- Iterator<ModelListener> iterator = _listeners.iterator;
- while (iterator.moveNext()) {
- if (iterator.current._onUpdate == onUpdate) {
- _listeners.remove(iterator.current);
- return;
- }
- }
- }
-
- void notifySuccess() {
- _listeners.forEach((listener) => listener.changed(this));
- }
-
- void notifyFailure() {
- _listeners.forEach((listener) => listener.failed());
- }
-}
-
-// Model of a set of listener functions to call when a model changes.
-class ModelListener {
- Function _onUpdate;
- Function _onFailure;
-
- ModelListener(this._onUpdate, this._onFailure) {}
-
- void changed(IsolateListModel model) => Function.apply(_onUpdate, [model]);
- void failed() => Function.apply(_onFailure, []);
-}
-
-
-// Model of the current running isolates.
-class IsolateListModel extends ObservableModel {
- List<Isolate> _isolates = [];
-
- void update() {
- HttpRequest.getString('/isolates').then(
- (Map response) => _onUpdate(JSON.parse(response)),
- onError: (e) => notifyFailure());
- }
-
- void _onUpdate(Map isolateMap) {
- _isolates = [];
- List list = isolateMap['isolates'];
- for (int i = 0; i < list.length; i++) {
- _isolates.add(new Isolate(list[i]));
- }
- notifySuccess();
- }
-
- String toString() {
- return _isolates.join(', ');
- }
-
- // List delegate method subset.
- Isolate elementAt(int index) => _isolates[index];
-
- void forEach(void f(Isolate element)) => _isolates.forEach(f);
-
- bool isEmpty() => _isolates.isEmpty;
-
- Iterator<Isolate> get iterator => _isolates.iterator;
-
- int get length => _isolates.length;
-
- Isolate operator[](int index) => _isolates[index];
-}
-
-
-// Model of a single isolate.
-class Isolate {
- final String handle;
- final String name;
- final int port;
- final int startTime;
- final int stackLimit;
- final Space newSpace;
- final Space oldSpace;
-
- // Create an isolate from a map describing an isolate in the observed VM.
- Isolate(Map raw):
- handle = raw['handle'],
- name = raw['name'],
- port = raw['port'],
- startTime = raw['starttime'],
- stackLimit = raw['stacklimit'],
- newSpace = new Space(raw['newspace']),
- oldSpace = new Space(raw['oldspace']) {}
-
- String toString() {
- return '$name: ${newSpace.used + oldSpace.used}K';
- }
-}
-
-// Model of a memory space.
-class Space {
- final int used;
- final int capacity;
-
- Space(Map raw): used = raw['used'], capacity = raw['capacity'] {}
-
- String toString() {
- return 'used: $used capacity: $capacity';
- }
-}
« no previous file with comments | « runtime/bin/vmstats/isolate_list.dart ('k') | runtime/bin/vmstats/packages/browser/dart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698