Files
sdk/pkg/observatory/web/timeline_message_handler.js
T
Ben Konyi d7cef28bee [ Observatory ] Create fork of runtime/observatory at pkg/observatory
This change further prepares for the removal of Observatory from the
shipped Dart SDK by creating a fork to be used by the remaining
Observatory users.

This is basically a straight copy of the contents from
runtime/observatory with the exception of two new scripts:

- `bin/observatory.dart`, a utility to launch Observatory
- `bin/activate.dart`, which globally activates `bin/observatory.dart`
  as `observatory`

This change also updates the presubmits to ensure that
`runtime/observatory` is effectively placed in read-only mode to prevent
any divergences with the fork.

Work towards https://github.com/dart-lang/sdk/issues/50233

Change-Id: Iff3a7512058f36afa2a96d45d94a1dff424401d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429800
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-05-22 07:19:03 -07:00

58 lines
1.6 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.
// Used to delay the initial timeline load until the timeline has finished
// loading.
timeline_loaded = false;
timeline_vm_address = undefined;
timeline_isolates = undefined;
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':
timeline_vm_address = params['vmAddress'];
timeline_isolates = params['isolateIds'];
if (typeof fetchTimeline === "undefined") {
console.log('Delaying timeline refresh until loaded.');
} else {
fetchTimeline(timeline_vm_address, timeline_isolates);
}
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');