Implemented reload-and-profile. Also fixed an couple of minor profiling bugs along the way

This commit is contained in:
Brian Vaughn
2019-03-27 09:41:12 -07:00
parent ea5f310fe1
commit 7d24e83989
7 changed files with 219 additions and 90 deletions
+11 -7
View File
@@ -61,13 +61,17 @@ port.onDisconnect.addListener(handleDisconnect);
window.addEventListener('message', handleMessageFromPage);
sayHelloToBackend();
// The backend waits to install the global hook until notified by the content script.
// In the event of a page reload, the content script might be loaded before the backend is injected.
// Because of this we need to poll the backend until it has been initialized.
const intervalID = setInterval(() => {
if (backendInitialized || backendDisconnected) {
clearInterval(intervalID);
} else {
sayHelloToBackend();
}
}, 500);
if (!backendInitialized) {
const intervalID = setInterval(() => {
if (backendInitialized || backendDisconnected) {
clearInterval(intervalID);
} else {
sayHelloToBackend();
}
}, 500);
}