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

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

Issue 187923009: Fix Dartium Observatory (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
« no previous file with comments | « no previous file | runtime/bin/vmservice/client/precommit.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 abstract class VM extends Observable { 7 abstract class VM extends Observable {
8 @observable ObservatoryApplication get app => _app; 8 @observable ObservatoryApplication get app => _app;
9 ObservatoryApplication _app; 9 ObservatoryApplication _app;
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 Future<String> fetchString(String path) { 87 Future<String> fetchString(String path) {
88 Logger.root.info('Fetching $path from $address'); 88 Logger.root.info('Fetching $path from $address');
89 return HttpRequest.getString(address + path); 89 return HttpRequest.getString(address + path);
90 } 90 }
91 } 91 }
92 92
93 class DartiumVM extends VM { 93 class DartiumVM extends VM {
94 final Map _outstandingRequests = new Map(); 94 final Map _outstandingRequests = new Map();
95 int _requestSerial = 0; 95 int _requestSerial = 0;
96 PostMessageRequestManager() { 96
97 DartiumVM() {
97 window.onMessage.listen(_messageHandler); 98 window.onMessage.listen(_messageHandler);
99 print('Connected to DartiumVM');
98 } 100 }
99 101
100 void _messageHandler(msg) { 102 void _messageHandler(msg) {
101 var id = msg.data['id']; 103 var id = msg.data['id'];
102 var name = msg.data['name']; 104 var name = msg.data['name'];
103 var data = msg.data['data']; 105 var data = msg.data['data'];
104 if (name != 'observatoryData') { 106 if (name != 'observatoryData') {
105 return; 107 return;
106 } 108 }
107 var completer = _outstandingRequests[id]; 109 var completer = _outstandingRequests[id];
108 assert(completer != null); 110 assert(completer != null);
109 _outstandingRequests.remove(id); 111 _outstandingRequests.remove(id);
110 completer.complete(data); 112 completer.complete(data);
111 } 113 }
112 114
113 Future<String> fetchString(String path) { 115 Future<String> fetchString(String path) {
114 var idString = '$_requestSerial'; 116 var idString = '$_requestSerial';
115 Map message = {}; 117 Map message = {};
116 message['id'] = idString; 118 message['id'] = idString;
117 message['method'] = 'observatoryQuery'; 119 message['method'] = 'observatoryQuery';
118 message['query'] = path; 120 message['query'] = '/$path';
119 _requestSerial++; 121 _requestSerial++;
120 var completer = new Completer(); 122 var completer = new Completer();
121 _outstandingRequests[idString] = completer; 123 _outstandingRequests[idString] = completer;
122 window.parent.postMessage(JSON.encode(message), '*'); 124 window.parent.postMessage(JSON.encode(message), '*');
123 return completer.future; 125 return completer.future;
124 } 126 }
125 } 127 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/vmservice/client/precommit.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698