Bug 1262312 - Don't update the device registration every time we open Sync preferences. r=markh draft
authorKit Cambridge <kcambridge@mozilla.com>
Tue, 05 Apr 2016 17:44:39 -0700
changeset 348300 5032f25e295bfb76ffead99d0e2d468f63a13b74
parent 348299 e7218494e54d7b0eeb2ef36cc2189bec7b002ee1
child 348301 212bc7c8971c762c25674a6413ca470fc228f965
push id14805
push userbmo:jacheng@mozilla.com
push dateThu, 07 Apr 2016 07:37:41 +0000
reviewersmarkh
bugs1262312
milestone48.0a1
Bug 1262312 - Don't update the device registration every time we open Sync preferences. r=markh MozReview-Commit-ID: 1rJbD1hHOAe
services/sync/modules/engines/clients.js
--- a/services/sync/modules/engines/clients.js
+++ b/services/sync/modules/engines/clients.js
@@ -121,21 +121,29 @@ ClientEngine.prototype = {
   },
 
   get brandName() {
     let brand = new StringBundle("chrome://branding/locale/brand.properties");
     return brand.get("brandShortName");
   },
 
   get localName() {
-    return this.localName = Utils.getDeviceName();
+    let name = Utils.getDeviceName();
+    // If `getDeviceName` returns the default name, set the pref. FxA registers
+    // the device before syncing, so we don't need to update the registration
+    // in this case.
+    Svc.Prefs.set("client.name", name);
+    return name;
   },
   set localName(value) {
     Svc.Prefs.set("client.name", value);
-    fxAccounts.updateDeviceRegistration();
+    // Update the registration in the background.
+    fxAccounts.updateDeviceRegistration().catch(error => {
+      this._log.warn("failed to update fxa device registration", error);
+    });
   },
 
   get localType() {
     return Utils.getDeviceType();
   },
   set localType(value) {
     Svc.Prefs.set("client.type", value);
   },