Files
sdk/runtime/observatory/web/timeline_message_handler.js
T
Ben Konyi c2c716d0c5 [ Observatory ] Fix issue where timeline would hang if CPU profiling was disabled.
When CPU profiling is disabled, the getCpuSamples RPC would return with
a ServerRpcException stating that the profiler was disabled. This wasn't
being caught when the RPC was invoked, but was being caught in
`ObservatoryApplication` and swallowed. This resulted in the timeline
page being stuck at the timeline loading dialog.

Also includes fixes from "[observatory] Properly wait for Catapult's iframe to load. Give
message while fetching timeline.", commit 3b99524167, which was reverted.

Change-Id: I2fe23d4dba5e20f717e111c519563866bb1a221c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126402
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2019-11-26 22:00:20 +00:00

53 lines
1.3 KiB
JavaScript

// Copyright (c) 2016, 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.
// This file is loaded before the about:tracing code is loaded so that we have
// an event listener registered early.
var traceObject;
function registerForMessages() {
window.addEventListener("message", onMessage, false);
window.addEventListener("hashchange", onHashChange, false);
}
registerForMessages();
function onMessage(event) {
var request = JSON.parse(event.data);
var method = request['method'];
var params = request['params'];
console.log('method: ' + method)
switch (method) {
case 'loading':
showLoadingOverlay('Fetching timeline...');
break;
case 'refresh':
traceObject = params;
if (typeof populateTimeline != 'undefined') {
populateTimeline();
} else {
console.log('populateTimeline is not yet defined');
}
break;
case 'clear':
clearTimeline();
break;
case 'save':
saveTimeline();
break;
case 'load':
loadTimeline();
break;
default:
console.log('Unknown method:' + method + '.');
}
}
function onHashChange() {
refreshTimeline();
}
console.log('message handler registered');