Bug 1262312 - Don't update the device registration every time we open Sync preferences. r=markh
authorKit Cambridge <kcambridge@mozilla.com>
Tue, 05 Apr 2016 17:44:39 -0700
changeset 291859 43f067177f2d15a3e3788b98cc18bd35441eb59e
parent 291858 7f54e6fc8add68c07c781e788182c4f9427aaa86
child 291860 df3d3e4187022772c3dfa8ffb591abb90632f0bb
push id74700
push usercbook@mozilla.com
push dateWed, 06 Apr 2016 10:06:38 +0000
treeherdermozilla-inbound@49d808d13f4f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1262312
milestone48.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 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);
   },