aboutsummaryrefslogtreecommitdiff
path: root/common/broadcast.js
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2021-12-16 14:37:09 +0100
committerWojtek Kosior <koszko@koszko.org>2021-12-16 14:37:09 +0100
commitb7378a9994724750198e0d165c575be8538334fb (patch)
tree1dd4a9252869591e85d21d5eb3e31c70a0fa0938 /common/broadcast.js
parent9a7623de1458f799baa109d0afbed08547874550 (diff)
downloadbrowser-extension-b7378a9994724750198e0d165c575be8538334fb.tar.gz
browser-extension-b7378a9994724750198e0d165c575be8538334fb.zip
facilitate tracking of IndexedDB item store contents
Diffstat (limited to 'common/broadcast.js')
-rw-r--r--common/broadcast.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/broadcast.js b/common/broadcast.js
index bc18103..cc11a20 100644
--- a/common/broadcast.js
+++ b/common/broadcast.js
@@ -59,6 +59,20 @@ function out(sender_conn, channel_name, value)
sender_conn.port.postMessage(["broadcast", channel_name, value]);
}
+/*
+ * prepare()'d message will be broadcasted if the connection is closed or when
+ * flush() is called. All messages prepared by given sender will be discarded
+ * when discard() is called.
+ *
+ * Timeout will cause the prepared message to be broadcasted after given number
+ * of miliseconds unless discard() is called in the meantime. It is mostly
+ * useful as a fallback in case this connection end gets nuked (e.g. because
+ * browser window is closed) and onDisconnect event is not dispatched to
+ * background script's Port object. This is only an issue for browsers as old as
+ * IceCat 60: https://bugzilla.mozilla.org/show_bug.cgi?id=1392067
+ *
+ * Timeout won't be scheduled at all if its value is given as 0.
+ */
function prepare(sender_conn, channel_name, value, timeout=5000)
{
sender_conn.port.postMessage(["prepare", channel_name, value, timeout]);