commit b08b54ba838ff8ee331389b0d9e5388620637b1c
parent 75f4360175f84ceeefe578fad971150a3de81892
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 7 Aug 2011 23:37:51 +0000
Add some documentation on the connector switching process
Diffstat:
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/xpcom/ipc.js b/chrome/content/zotero/xpcom/ipc.js
@@ -49,16 +49,38 @@ Zotero.IPC = new function() {
if(!msg) continue;
Zotero.debug('IPC: Received "'+msg+'"');
+ /*
+ * The below messages coordinate switching Zotero for Firefox from extension mode to
+ * connector mode without restarting after Zotero Standalone has been launched. The
+ * dance typically proceeds as follows:
+ *
+ * 1. SA sends a releaseLock message to Z4Fx that tells it to release its lock.
+ * 2. Z4Fx releases its lock and sends a lockReleased message to SA.
+ * 3. Z4Fx restarts in connector mode. Once it's ready for an IPC command, it sends
+ * a checkInitComplete message to SA.
+ * 4. Once SA finishes initializing, or immediately after a checkInitComplete message
+ * has been received if it is already initialized, SA sends an initComplete message
+ * to Z4Fx.
+ */
if(msg === "releaseLock" && !Zotero.isConnector) {
+ // Standalone sends this to the Firefox extension to tell the Firefox extension to
+ // release its lock on the Zotero database
switchConnectorMode(true);
} else if(msg === "lockReleased") {
+ // The Firefox extension sends this to Standalone to let Standalone know that it has
+ // released its lock
Zotero.onDBLockReleased();
} else if(msg === "checkInitComplete") {
+ // The Firefox extension sends this to Standalone to tell Standalone to send an
+ // initComplete message when it is fully initialized
while(!Zotero.initialized) {
Zotero.mainThread.processNextEvent(true)
}
Zotero.IPC.broadcast("initComplete");
} else if(msg === "initComplete") {
+ // Standalone sends this to the Firefox extension to let the Firefox extension
+ // know that Standalone has fully initialized and it should pull the list of
+ // translators
Zotero.onInitComplete();
}
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -185,10 +185,6 @@ if(appInfo.platformVersion[0] >= 2) {
// whether we are waiting for another Zotero process to initialize so we can use connector
var _waitingForInitComplete = false;
- // whether we should broadcast an initComplete message when initialization finishes (we should
- // do this if we forced another Zotero process to release its lock)
- var _broadcastInitComplete = false;
-
/**
* Maintains nsITimers to be used when Zotero.wait() completes (to reduce performance penalty
* of initializing new objects)