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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/app/application.dart

Issue 192443004: Complete the switch to ServiceObject (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// A request response interceptor is called for each response. 7 /// A request response interceptor is called for each response.
8 typedef void RequestResponseInterceptor(); 8 typedef void RequestResponseInterceptor();
9 9
10 /// The observatory application. Instances of this are created and owned 10 /// The observatory application. Instances of this are created and owned
11 /// by the observatory_application custom element. 11 /// by the observatory_application custom element.
12 class ObservatoryApplication extends Observable { 12 class ObservatoryApplication extends Observable {
13 @observable final LocationManager locationManager; 13 @observable final LocationManager locationManager;
14 @observable final VM vm; 14 @observable final VM vm;
15 @observable Map response;
16 @observable Isolate isolate; 15 @observable Isolate isolate;
16 @observable ServiceObject response;
17 17
18 void setResponse(Map response) { 18 void setResponse(ServiceObject response) {
19 this.response = toObservable(response); 19 this.response = response;
20 } 20 }
21 21
22 void setResponseError(String message, [String errorType = 'ResponseError']) { 22 void _initOnce() {
23 this.response = toObservable({ 23 // Only called once.
24 'type': 'Error', 24 assert(locationManager._app == null);
25 'errorType': errorType,
26 'text': message
27 });
28 Logger.root.severe(message);
29 }
30
31 void _setup() {
32 vm._app = this;
33 locationManager._app = this; 25 locationManager._app = this;
34 locationManager.init(); 26 locationManager.init();
35 } 27 }
36 28
37 ObservatoryApplication.devtools() : 29 ObservatoryApplication.devtools() :
38 locationManager = new LocationManager(), 30 locationManager = new LocationManager(),
39 vm = new DartiumVM() { 31 vm = new DartiumVM() {
40 _setup(); 32 _initOnce();
41 } 33 }
42 34
43 ObservatoryApplication() : 35 ObservatoryApplication() :
44 locationManager = new LocationManager(), 36 locationManager = new LocationManager(),
45 vm = new HttpVM('http://127.0.0.1:8181/') { 37 vm = new HttpVM('http://127.0.0.1:8181/') {
46 _setup(); 38 _initOnce();
47 }
48
49 static const int KB = 1024;
50 static const int MB = KB * 1024;
51 static String scaledSizeUnits(int x) {
52 if (x > 2 * MB) {
53 var y = x / MB;
54 return '${y.toStringAsFixed(1)} MB';
55 } else if (x > 2 * KB) {
56 var y = x / KB;
57 return '${y.toStringAsFixed(1)} KB';
58 }
59 var y = x.toDouble();
60 return '${y.toStringAsFixed(1)} B';
61 }
62
63 static String timeUnits(double x) {
64 return x.toStringAsFixed(2);
65 } 39 }
66 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698