Bug 982893: give up on not trying to initialize Weave.Status on window open, since we were failing at it anyways, r=markh
authorGavin Sharp <gavin@gavinsharp.com>
Thu, 13 Mar 2014 09:52:52 -0700
changeset 190673 8260554d3422bea9b0edfa9ccbc830a4adfd105c
parent 190672 549baf11d2c04bb503960c3c03f54b1128b98ae3
child 190674 75f3bd5737a6704c456535f206de6c09adbd9381
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs982893
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 982893: give up on not trying to initialize Weave.Status on window open, since we were failing at it anyways, r=markh Changes: * don't try to avoid loading Weave.Status modules on window open * access the authManager via Weave.Status instead of Weave.Service, since Weave.Status will already be initialized in almost all cases.
browser/base/content/browser-syncui.js
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -83,55 +83,40 @@ let gSyncUI = {
 
     // notificationbox will listen to observers from now on.
     Services.obs.removeObserver(this, "weave:notification:added");
   },
 
   _wasDelayed: false,
 
   _needsSetup: function SUI__needsSetup() {
-    // We want to treat "account needs verification" as "needs setup". We don't
-    // know what the user's verified state is until Sync is initialized, though,
-    // and we need to get an answer here synchronously (can't wait for
-    // getSignedInUser). So "reach in" to Weave.Service.identity to get the
-    // answer here, and we'll just have to deal with this not having an answer
-    // before Sync is initialized.
-
-    // Referencing Weave.Service will implicitly initialize sync, and we don't
-    // want to force that - so first check if it is ready.
-    let service = Cc["@mozilla.org/weave/service;1"]
-                  .getService(Components.interfaces.nsISupports)
-                  .wrappedJSObject;
-    if (service.ready && Weave.Service.identity._signedInUser) {
+    // We want to treat "account needs verification" as "needs setup". So
+    // "reach in" to Weave.Status._authManager to check whether we the signed-in
+    // user is verified.
+    // Referencing Weave.Status spins a nested event loop to initialize the
+    // authManager, so this should always return a value directly.
+    // This only applies to fxAccounts-based Sync.
+    if (Weave.Status._authManager._signedInUser) {
       // If we have a signed in user already, and that user is not verified,
       // revert to the "needs setup" state.
-      if (!Weave.Service.identity._signedInUser.verified) {
+      if (!Weave.Status._authManager._signedInUser.verified) {
         return true;
       }
     }
 
     let firstSync = "";
     try {
       firstSync = Services.prefs.getCharPref("services.sync.firstSync");
     } catch (e) { }
 
     return Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
            firstSync == "notReady";
   },
 
   _loginFailed: function () {
-    // Referencing Weave.Status will import a bunch of modules, and we don't
-    // want to force that - so first check if it is ready.
-    let service = Cc["@mozilla.org/weave/service;1"]
-                  .getService(Components.interfaces.nsISupports)
-                  .wrappedJSObject;
-    if (!service.ready) {
-      return false;
-    }
-
     return Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED;
   },
 
   updateUI: function SUI_updateUI() {
     let needsSetup = this._needsSetup();
     let loginFailed = this._loginFailed();
 
     // Start off with a clean slate