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

Side by Side Diff: runtime/observatory/web/timeline.js

Issue 1847043003: Automatically fetch timeline when timeline page is loaded (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « runtime/observatory/lib/src/elements/timeline_page.html ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // Used to delay the initial timeline load until the timeline has finished
6 // loading.
7 timeline_loaded = false;
8 timeline_vm_address = undefined;
9 timeline_isolates = undefined;
10
11 function registerForMessages() {
12 window.addEventListener("message", onMessage, false);
13 }
14
15 registerForMessages();
16
5 function onModelLoaded() { 17 function onModelLoaded() {
6 viewer.globalMode = true; 18 viewer.globalMode = true;
7 viewer.model = model; 19 viewer.model = model;
8 } 20 }
9 21
10 function clearTimeline() { 22 function clearTimeline() {
11 viewer.model = undefined; 23 viewer.model = undefined;
12 } 24 }
13 25
14 function onImportFail() { 26 function onImportFail() {
15 var overlay = new tr.ui.b.Overlay(); 27 var overlay = new tr.ui.b.Overlay();
16 overlay.textContent = tr.b.normalizeException(err).message; 28 overlay.textContent = tr.b.normalizeException(err).message;
17 overlay.title = 'Import error'; 29 overlay.title = 'Import error';
18 overlay.visible = true; 30 overlay.visible = true;
19 console.log('import failed'); 31 console.log('import failed');
20 } 32 }
21 33
22 function updateTimeline(events) { 34 function updateTimeline(events) {
23 model = new tr.Model(); 35 model = new tr.Model();
24 var importer = new tr.importer.Import(model); 36 var importer = new tr.importer.Import(model);
25 var p = importer.importTracesWithProgressDialog([events]); 37 var p = importer.importTracesWithProgressDialog([events]);
26 p.then(onModelLoaded, onImportFail); 38 p.then(onModelLoaded, onImportFail);
27 } 39 }
28 40
29 function registerForMessages() { 41
30 window.addEventListener("message", onMessage, false);
31 }
32 42
33 function fetchUri(uri, onLoad, onError) { 43 function fetchUri(uri, onLoad, onError) {
34 var xhr = new XMLHttpRequest(); 44 var xhr = new XMLHttpRequest();
35 xhr.open('GET', uri, true); 45 xhr.open('GET', uri, true);
36 xhr.responseType = 'text'; 46 xhr.responseType = 'text';
37 xhr.addEventListener("load", onLoad); 47 xhr.addEventListener("load", onLoad);
38 xhr.addEventListener("error", onError); 48 xhr.addEventListener("error", onError);
39 xhr.send(); 49 xhr.send();
40 console.log('GET ' + uri); 50 console.log('GET ' + uri);
41 } 51 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 }); 199 });
190 inputElement.click(); 200 inputElement.click();
191 } 201 }
192 202
193 function onMessage(event) { 203 function onMessage(event) {
194 var request = JSON.parse(event.data); 204 var request = JSON.parse(event.data);
195 var method = request['method']; 205 var method = request['method'];
196 var params = request['params']; 206 var params = request['params'];
197 switch (method) { 207 switch (method) {
198 case 'refresh': 208 case 'refresh':
199 fetchTimeline(params['vmAddress'], params['isolateIds']); 209 if (!timeline_loaded) {
210 timeline_vm_address = params['vmAddress'];
211 timeline_isolates = params['isolateIds'];
212 console.log('Delaying timeline refresh until loaded.');
213 } else {
214 fetchTimeline(params['vmAddress'], params['isolateIds']);
215 }
200 break; 216 break;
201 case 'clear': 217 case 'clear':
202 clearTimeline(); 218 clearTimeline();
203 break; 219 break;
204 case 'save': 220 case 'save':
205 saveTimeline(); 221 saveTimeline();
206 break; 222 break;
207 case 'load': 223 case 'load':
208 loadTimeline(); 224 loadTimeline();
209 break; 225 break;
210 default: 226 default:
211 console.log('Unknown method:' + method + '.'); 227 console.log('Unknown method:' + method + '.');
212 } 228 }
213 } 229 }
214 230
215 document.addEventListener('DOMContentLoaded', function() { 231 document.addEventListener('DOMContentLoaded', function() {
216 var container = document.createElement('track-view-container'); 232 var container = document.createElement('track-view-container');
217 container.id = 'track_view_container'; 233 container.id = 'track_view_container';
218 viewer = document.createElement('tr-ui-timeline-view'); 234 viewer = document.createElement('tr-ui-timeline-view');
219 viewer.track_view_container = container; 235 viewer.track_view_container = container;
220 viewer.appendChild(container); 236 viewer.appendChild(container);
221 viewer.id = 'trace-viewer'; 237 viewer.id = 'trace-viewer';
222 viewer.globalMode = true; 238 viewer.globalMode = true;
223 document.body.appendChild(viewer); 239 document.body.appendChild(viewer);
224 registerForMessages(); 240 timeline_loaded = true;
241 if (timeline_vm_address != undefined) {
242 console.log('Triggering delayed timeline refresh.');
243 fetchTimeline(timeline_vm_address, timeline_isolates);
244 timeline_vm_address = undefined;
245 timeline_isolates = undefined;
246 }
225 }); 247 });
226 248
227 console.log('loaded'); 249 console.log('loaded');
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/timeline_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698