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 347848 90bcb9699f827fb2c57b77f0bf39eec0bafb539d
parent 347846 d740790c015dba28b64b39c947b38a07b61cf6dc
child 517732 4be2a48905d57bc9846949078591635d61a41055
push id14694
push userkcambridge@mozilla.com
push dateWed, 06 Apr 2016 00:50:12 +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);
   },