Bug 788561 - SettingsAPI: Use createLock instead of getLock. r=bent
authorGregor Wagner <anygregor@gmail.com>
Wed, 05 Sep 2012 17:33:03 -0700
changeset 110692 195a99db216afc13cd509db86922232a9a8c7c12
parent 110691 cd952fc4507b0cef04e6e9dc6522fee144fcb98a
child 110693 9bcd2ea9da6bce96b98f7095c9987fc1421fd344
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs788561
milestone18.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 788561 - SettingsAPI: Use createLock instead of getLock. r=bent
b2g/chrome/content/runapp.js
b2g/chrome/content/settings.js
dom/interfaces/settings/nsIDOMSettingsManager.idl
dom/interfaces/settings/nsISettingsService.idl
dom/settings/SettingsManager.js
dom/settings/SettingsManager.manifest
dom/settings/SettingsService.js
dom/settings/SettingsService.manifest
dom/settings/tests/test_settings_basics.html
dom/system/gonk/AutoMounterSetting.cpp
dom/system/gonk/NetworkManager.js
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/TimeSetting.cpp
dom/tests/mochitest/geolocation/test_mozsettings.html
dom/tests/mochitest/geolocation/test_mozsettingsWatch.html
dom/wifi/WifiWorker.js
xpcom/tests/TestSettingsAPI.cpp
--- a/b2g/chrome/content/runapp.js
+++ b/b2g/chrome/content/runapp.js
@@ -67,17 +67,17 @@ window.addEventListener('load', function
     let app = findAppWithName(appname);
     if (!app) {
       dump('Could not find app: "' + appname + '". Maybe you meant one of:\n');
       usageAndDie(true);
       return;
     }
 
     let setReq =
-      navigator.mozSettings.getLock().set({'lockscreen.enabled': false});
+      navigator.mozSettings.createLock().set({'lockscreen.enabled': false});
     setReq.onsuccess = function() {
       // give the event loop another turn to disable the lock screen
       window.setTimeout(function() {
         dump('--runapp launching app: ' + app.manifest.name + '\n');
         app.launch();
       }, 0);
     };
     setReq.onerror = function() {
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -30,17 +30,17 @@ var SettingsListener = {
       window.setTimeout(function() { callback(defaultValue); });
       return;
     }
 
     if (!callback || typeof callback !== 'function') {
       throw new Error('Callback is not a function');
     }
 
-    var req = settings.getLock().get(name);
+    var req = settings.createLock().get(name);
     req.addEventListener('success', (function onsuccess() {
       callback(typeof(req.result[name]) != 'undefined' ?
         req.result[name] : defaultValue);
     }));
 
     this._callbacks[name] = callback;
   }
 };
--- a/dom/interfaces/settings/nsIDOMSettingsManager.idl
+++ b/dom/interfaces/settings/nsIDOMSettingsManager.idl
@@ -15,18 +15,19 @@ interface nsIDOMSettingsLock : nsISuppor
   nsIDOMDOMRequest set(in nsIVariant settings);
 
   // result contains the value of the setting.
   nsIDOMDOMRequest get(in jsval name);
 
   nsIDOMDOMRequest clear();
 };
 
-[scriptable, uuid(dd9f5380-a454-11e1-b3dd-0800200c9a66)]
+[scriptable, uuid(0694f5e0-f777-11e1-a21f-0800200c9a66)]
 interface nsIDOMSettingsManager : nsISupports
 {
+  nsIDOMSettingsLock createLock();
   nsIDOMSettingsLock getLock();
 
   void addObserver(in DOMString name, in jsval callback);
   void removeObserver(in DOMString name, in jsval callback);
 
   attribute nsIDOMEventListener onsettingchange;
 };
--- a/dom/interfaces/settings/nsISettingsService.idl
+++ b/dom/interfaces/settings/nsISettingsService.idl
@@ -19,13 +19,13 @@ interface nsISettingsServiceLock : nsISu
   void set(in string aName,
            in jsval aValue,
            in nsISettingsServiceCallback aCallback,
            [optional] in string aMessage);
 
   void get(in string aName, in nsISettingsServiceCallback aCallback);
 };
 
-[scriptable, uuid(3458e760-8513-11e1-b0c4-0800200c9a66)]
+[scriptable, uuid(f656f0c0-f776-11e1-a21f-0800200c9a66)]
 interface nsISettingsService : nsISupports
 {
-  nsISettingsServiceLock getLock();
+  nsISettingsServiceLock createLock();
 };
--- a/dom/settings/SettingsManager.js
+++ b/dom/settings/SettingsManager.js
@@ -204,17 +204,17 @@ SettingsLock.prototype = {
   classInfo : XPCOMUtils.generateCI({classID: SETTINGSLOCK_CID,
                                      contractID: SETTINGSLOCK_CONTRACTID,
                                      classDescription: "SettingsLock",
                                      interfaces: [nsIDOMSettingsLock],
                                      flags: nsIClassInfo.DOM_OBJECT})
 };
 
 const SETTINGSMANAGER_CONTRACTID = "@mozilla.org/settingsManager;1";
-const SETTINGSMANAGER_CID        = Components.ID("{dd9f5380-a454-11e1-b3dd-0800200c9a66}");
+const SETTINGSMANAGER_CID        = Components.ID("{0694f5e0-f777-11e1-a21f-0800200c9a66}");
 const nsIDOMSettingsManager      = Ci.nsIDOMSettingsManager;
 
 let myGlobal = this;
 
 function SettingsManager()
 {
   this._locks = new Queue();
   if (!("indexedDB" in myGlobal)) {
@@ -242,28 +242,33 @@ SettingsManager.prototype = {
     else
       throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
   },
 
   get onsettingchange() {
     return this._onsettingchange;
   },
 
-  getLock: function() {
+  createLock: function() {
     debug("get lock!");
     var lock = new SettingsLock(this);
     this._locks.enqueue(lock);
     this._settingsDB.ensureDB(
       function() { lock.createTransactionAndProcess(); },
       function() { dump("ensureDB error cb!\n"); },
       myGlobal );
     this.nextTick(function() { this._open = false; }, lock);
     return lock;
   },
 
+  getLock: function() {
+    dump("WARNING: Use createLock instead of getLock!");
+    return this.createLock();
+  },
+
   receiveMessage: function(aMessage) {
     debug("Settings::receiveMessage: " + aMessage.name);
     let msg = aMessage.json;
 
     switch (aMessage.name) {
       case "Settings:Change:Return:OK":
         debug("Settings:Change:Return:OK");
         if (this._onsettingchange || this._callbacks) {
--- a/dom/settings/SettingsManager.manifest
+++ b/dom/settings/SettingsManager.manifest
@@ -1,6 +1,6 @@
-component {dd9f5380-a454-11e1-b3dd-0800200c9a66} SettingsManager.js
-contract @mozilla.org/settingsManager;1 {dd9f5380-a454-11e1-b3dd-0800200c9a66}
+component {0694f5e0-f777-11e1-a21f-0800200c9a66} SettingsManager.js
+contract @mozilla.org/settingsManager;1 {0694f5e0-f777-11e1-a21f-0800200c9a66}
 category JavaScript-navigator-property mozSettings @mozilla.org/settingsManager;1
 
 component {ef95ddd0-6308-11e1-b86c-0800200c9a66} SettingsManager.js
 contract @mozilla.org/settingsLock;1 {ef95ddd0-6308-11e1-b86c-0800200c9a66}
--- a/dom/settings/SettingsService.js
+++ b/dom/settings/SettingsService.js
@@ -136,17 +136,17 @@ SettingsServiceLock.prototype = {
 
   classInfo : XPCOMUtils.generateCI({ classID: SETTINGSSERVICELOCK_CID,
                                       contractID: SETTINGSSERVICELOCK_CONTRACTID,
                                       classDescription: "SettingsServiceLock",
                                       interfaces: [nsISettingsServiceLock],
                                       flags: nsIClassInfo.DOM_OBJECT })
 };
 
-const SETTINGSSERVICE_CID        = Components.ID("{3458e760-8513-11e1-b0c4-0800200c9a66}");
+const SETTINGSSERVICE_CID        = Components.ID("{f656f0c0-f776-11e1-a21f-0800200c9a66}");
 
 let myGlobal = this;
 
 function SettingsService()
 {
   debug("settingsService Constructor");
   this._locks = new Queue();
   if (!("indexedDB" in myGlobal)) {
@@ -161,17 +161,17 @@ SettingsService.prototype = {
 
   nextTick: function nextTick(aCallback, thisObj) {
     if (thisObj)
       aCallback = aCallback.bind(thisObj);
 
     Services.tm.currentThread.dispatch(aCallback, Ci.nsIThread.DISPATCH_NORMAL);
   },
 
-  getLock: function getLock() {
+  createLock: function createLock() {
     debug("get lock!");
     var lock = new SettingsServiceLock(this);
     this._locks.enqueue(lock);
     this._settingsDB.ensureDB(
       function() { lock.createTransactionAndProcess(); },
       function() { dump("ensureDB error cb!\n"); },
       myGlobal );
     this.nextTick(function() { this._open = false; }, lock);
--- a/dom/settings/SettingsService.manifest
+++ b/dom/settings/SettingsService.manifest
@@ -1,5 +1,5 @@
 component {d7a395a0-e292-11e1-834e-1761d57f5f99} SettingsService.js
 contract @mozilla.org/settingsServiceLock;1 {d7a395a0-e292-11e1-834e-1761d57f5f99}
 
-component {3458e760-8513-11e1-b0c4-0800200c9a66} SettingsService.js
-contract @mozilla.org/settingsService;1 {3458e760-8513-11e1-b0c4-0800200c9a66}
+component {f656f0c0-f776-11e1-a21f-0800200c9a66} SettingsService.js
+contract @mozilla.org/settingsService;1 {f656f0c0-f776-11e1-a21f-0800200c9a66}
--- a/dom/settings/tests/test_settings_basics.html
+++ b/dom/settings/tests/test_settings_basics.html
@@ -84,149 +84,149 @@ function check(o1, o2) {
 var req, req2, req3, req4, req5, req6;
 var index = 0;
 
 var mozSettings = window.navigator.mozSettings;
 
 var steps = [
   function () {
     ok(true, "Deleting database");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.clear();
     req.onsuccess = function () {
       ok(true, "Deleted the database");
     };
     req.onerror = onFailure;
     req2 = lock.set(screenBright);
     req2.onsuccess = function () {
       ok(true, "set done");
       next();
     }
     req2.onerror = onFailure;
   },
   function() {
     ok(true, "Get unknown key");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("abc.def");
     req.onsuccess = function() {
       is(req.result["abc.def"], undefined, "no result");
       next();
     };
     req.onerror = onFailure;
   },
   function() {
     ok(true, "adding onsettingchange");
     navigator.mozSettings.onsettingchange = onsettingschangeWithNext;
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req2 = lock.get("screen.brightness");
     req2.onsuccess = function() {
       ok(true, "end adding onsettingchange");
       next();
     };
     req2.onerror = onFailure;
   },
   function() {
     ok(true, "Test onsettingchange");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(screenBright);
     req.onsuccess = function () {
       ok(true, "set done, observer has to call next");
     }
     req.onerror = onFailure;
   },
   function() {
     ok(true, "delete onsettingschange");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     navigator.mozSettings.onsettingchange = null;
     req = lock.set(screenBright);
     req.onsuccess = function () {
       ok(true, "set done");
       next();
     }
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Waiting for all set callbacks");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("screen.brightness");
     req.onsuccess = function() {
       ok(true, "Done");
       next();
     }
     req.onerror = onFailure;
   },
   function() {
     ok(true, "adding Observers 1");
     navigator.mozSettings.addObserver("screen.brightness", observer1);
     navigator.mozSettings.addObserver("screen.brightness", observer1);
     navigator.mozSettings.addObserver("screen.brightness", observer2);
     navigator.mozSettings.addObserver("screen.brightness", observerWithNext);
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req2 = lock.get("screen.brightness");
     req2.onsuccess = function() {
       ok(true, "set observeSetting done!");
       next();
     };
     req2.onerror = onFailure;
   },
   function() {
     ok(true, "test observers");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(screenBright);
     req.onsuccess = function () {
       ok(true, "set done");
     }
     req.onerror = onFailure;
   },
   function() {
     ok(true, "removing Event Listener");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(screenBright);
     req.onsuccess = function () {
       ok(true, "set done");
       navigator.mozSettings.removeObserver("screen.brightness", observer2);
       navigator.mozSettings.removeObserver("screen.brightness", observer1);
     }
     req.onerror = onFailure;
   },
   function() {
     ok(true, "test Event Listener");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(screenBright);
     req.onsuccess = function () {
       ok(true, "set done");
     }
     req.onerror = onFailure;
   },
   function() {
     ok(true, "removing Event Listener");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     navigator.mozSettings.removeObserver("screen.brightness", observerWithNext);
     req = lock.set(screenBright);
     req.onsuccess = function () {
       ok(true, "set done");
       navigator.mozSettings.removeObserver("screen.brightness", observer2);
       navigator.mozSettings.removeObserver("screen.brightness", observer1);
       next();
     }
     req.onerror = onFailure;
   },
   function() {
     ok(true, "removing Event Listener");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("screen.brightness");
     req.onsuccess = function () {
       ok(true, "get done");
       next();
     }
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Nested test");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("screen.brightness");
     req.onsuccess = function () {
       req3 = lock.set({"screen.brightness": req.result["screen.brightness"] + 1})
       req3.onsuccess = function () {
         req4 = lock.get("screen.brightness");
         req4.onsuccess = function() {
           is(req4.result["screen.brightness"], 1.7, "same Value");
         }
@@ -237,40 +237,40 @@ var steps = [
     req.onerror = onFailure;
 
     req2 = lock.get("screen.brightness");
     req2.onsuccess = function () {
       is(req2.result["screen.brightness"], 0.7, "same Value");
     }
     req2.onerror = onFailure;
     
-    var lock2 = mozSettings.getLock();
+    var lock2 = mozSettings.createLock();
     req5 = lock2.get("screen.brightness");
     req5.onsuccess = function () {
       is(req5.result["screen.brightness"], 1.7, "same Value");
       next();
     }
     req5.onerror = onFailure;
   },
   function () {
     ok(true, "Deleting database");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.clear();
     req.onsuccess = function () {
       ok(true, "Deleted the database");
     };
     req.onerror = onFailure;
     req2 = lock.set(wifi);
     req2.onsuccess = function () {
       ok(true, "set done");
     }
     req2.onerror = onFailure;
 
     ok(true, "Get all settings");
-    var lock2 = mozSettings.getLock();
+    var lock2 = mozSettings.createLock();
     req = lock2.get("*");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 1, "length 1");
       check(wifi, req.result);
       ok(true, JSON.stringify(req.result));
       ok(true, "Get all settings Done");
     };
     req.onerror = onFailure;
@@ -281,17 +281,17 @@ var steps = [
       check(wifi, req2.result);
       ok(true, "Get net3g.apn Done");
       next();
     };
     req2.onerror = onFailure;
   },
   function () {
     ok(true, "Change wifi");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(wifi2);
     req.onsuccess = function () {
       ok(true, "Set Done");
     };
     req.onerror = onFailure;
 
     ok(true, "Get changed net3g.apn");
     req2 = lock.get("net3g.apn");
@@ -300,139 +300,139 @@ var steps = [
       check(wifi2, req2.result);
       ok(true, "Get net3g.apn Done");
       next();
     };
     req2.onerror = onFailure;
   },
   function () {
     ok(true, "Test locking");
-    var lock = mozSettings.getLock();
-    var lock2 = mozSettings.getLock();
+    var lock = mozSettings.createLock();
+    var lock2 = mozSettings.createLock();
     req = lock.set(wifiEnabled);
     req.onsuccess = function () {
       ok(true, "Test Locking Done");
     };
     req.onerror = onFailure;
 
     req2 = lock2.set(wifiDisabled);
     req2.onsuccess = function () {
       ok(true, "Set Done");
       next();
     };
     req2.onerror = onFailure;
   },
   function () {
     ok(true, "Test locking result");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("wifi.enabled");
     req.onsuccess = function() {
       check(req.result, wifiDisabled);
       ok(true, "Test1 locking result done");
       next();
     }
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Test locking heavy");
     for (var i=0; i<30; i++) {
       // only new locks!
-      var lock = mozSettings.getLock();
+      var lock = mozSettings.createLock();
       var obj = {};
       obj["wifi.enabled" + i] = true;
       req = lock.set( obj );
       req.onsuccess = function () {
         ok(true, "Set1 Done");
       };
       req.onerror = onFailure;
     };
     {
-      var lock2 = mozSettings.getLock();
+      var lock2 = mozSettings.createLock();
       req = lock2.get("*");
       req.onsuccess = function () {
         is(Object.keys(req.result).length, 32, "length 12");
         ok(true, JSON.stringify(req.result));
         ok(true, "Get all settings Done");
       };
       req.onerror = onFailure;
     }
-    var lock2 = mozSettings.getLock();
+    var lock2 = mozSettings.createLock();
     var obj = {};
     obj["wifi.enabled" + 30] = true;
     req2 = lock2.set( obj );
     req2.onsuccess = function () {
       ok(true, "Set12 Done");
     };
     req2.onerror = onFailure;
 
-    var lock3 = mozSettings.getLock();
+    var lock3 = mozSettings.createLock();
     // with one lock
     for (var i = 0; i < 30; i++) {
       req3 = lock3.get("wifi.enabled" + i);
       var testObj = {};
       testObj["wifi.enabled" + i] = true;
       req3.onsuccess = function () {
         check(this.request.result, this.testObj);
         ok(true, "Get1 Done");
       }.bind({testObj: testObj, request: req3});
       req3.onerror = onFailure;
     }
 
     ok(true, "start next2!");
-    var lock4 = mozSettings.getLock();
+    var lock4 = mozSettings.createLock();
     for (var i=0; i<30; i++) {
       var obj = {};
       obj["wifi.enabled" + i] = false;
       req4 = lock4.set( obj );
       req4.onsuccess = function () {
         ok(true, "Set2 Done");
       };
       req4.onerror = onFailure;
     }
-    var lock5 = mozSettings.getLock();
+    var lock5 = mozSettings.createLock();
     for (var i=0; i<30; i++) {
       req5 = lock5.get("wifi.enabled" + i);
       var testObj = {};
       testObj["wifi.enabled" + i] = false;
       req5.onsuccess = function () {
         check(this.request.result, this.testObj);
         ok(true, "Get2 Done");
       }.bind({testObj: testObj, request: req5});
       req5.onerror = onFailure;
     }
     
-    var lock5 = mozSettings.getLock();
+    var lock5 = mozSettings.createLock();
     req6 = lock5.clear();
     req6.onsuccess = function () {
       ok(true, "Deleted the database");
       next();
     };
     req6.onerror = onFailure;
   },
   function () {
     ok(true, "reverse Test locking");
-    var lock2 = mozSettings.getLock();
-    var lock = mozSettings.getLock();
+    var lock2 = mozSettings.createLock();
+    var lock = mozSettings.createLock();
 
     req = lock.set(wifiEnabled);
     req.onsuccess = function () {
       ok(true, "Test Locking Done");
       next();
     };
     req.onerror = onFailure;
 
     req2 = lock2.set(wifiDisabled);
     req2.onsuccess = function () {
       ok(true, "Set Done");
     };
     req2.onerror = onFailure;
   },
   function () {
     ok(true, "Test locking result");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     
     req = lock.get("wifi.enabled");
     req.onsuccess = function() {
       check(req.result, wifiEnabled);
       ok(true, "Test2 locking result done");
     }
     req.onerror = onFailure;
     
@@ -447,167 +447,167 @@ var steps = [
       ok(true, "set done");
       next();
     }
     req3.onerror = onFailure;
     
   },
   function () {
     ok(true, "Get all settings");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("*");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 1, "length 1");
       check(wifi, req.result);
       ok(true, "Get all settings Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Get net3g.apn");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("net3g.apn");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 1, "length 1");
       check(wifi, req.result);
       ok(true, "Get net3g.apn Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Change wifi");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(wifi2);
     req.onsuccess = function () {
       ok(true, "Set Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Get net3g.apn");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("net3g.apn");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 1, "length 1");
       check(wifi2, req.result);
       ok(true, "Get net3g.apn Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Add wifi.enabled");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(wifiEnabled);
     req.onsuccess = function () {
       ok(true, "Set Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Get Wifi Enabled");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("wifi.enabled");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 1, "length 1");
       check(wifiEnabled, req.result);
       ok(true, "Get wifi.enabledDone");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Get all");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("*");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 2, "length 2");
       check(wifiEnabled["wifi.enabled"], req.result["wifi.enabled"]);
       check(wifi2["net3g.apn"], req.result["net3g.apn"]);
       ok(true, "Get all Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Add wifiNetworks");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(wifiNetworks0);
     req.onsuccess = function () {
       ok(true, "Set Done");
     };
     req.onerror = onFailure;
 
     req2 = lock.set(wifiNetworks1);
     req2.onsuccess = function () {
       ok(true, "Set Done");
       next();
     };
     req2.onerror = onFailure;
   },
   function () {
     ok(true, "Get Wifi Networks");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.get("wifi.networks[0]");
     req.onsuccess = function () {
       is(Object.keys(req.result).length, 1, "length 1");
       check(wifiNetworks0, req.result);
       ok(true, "Get wifi.networks[0]");
       next();
     };
     req.onerror = onFailure;
   },
   function() {
     ok(true, "Clear DB, multiple locks");
-    var lock4 = mozSettings.getLock();
-    var lock3 = mozSettings.getLock();
-    var lock2 = mozSettings.getLock();
-    var lock = mozSettings.getLock();
-    var lock6 = mozSettings.getLock();
-    var lock7 = mozSettings.getLock();
+    var lock4 = mozSettings.createLock();
+    var lock3 = mozSettings.createLock();
+    var lock2 = mozSettings.createLock();
+    var lock = mozSettings.createLock();
+    var lock6 = mozSettings.createLock();
+    var lock7 = mozSettings.createLock();
     req = lock.clear();
     req.onsuccess = function () {
       ok(true, "Deleted the database");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Add wifiNetworks");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.set(wifiNetworks0);
     req.onsuccess = function () {
       ok(true, "Set Done");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Test set after lock closed");
-    var lockx = mozSettings.getLock();
+    var lockx = mozSettings.createLock();
     var cb = function() {
       var reqx = null;
       try {
         reqx = lockx.set(wifiNetworks0);
         ok(false, "should have thrown");
       } catch (ex) {
         ok(reqx == null, "request is still null");
         ok(true, "Caught Exception");
         next();
       }
     }
     SimpleTest.executeSoon(cb);
   },
   function() {
     ok(true, "Clear DB");
-    var lock = mozSettings.getLock();
+    var lock = mozSettings.createLock();
     req = lock.clear();
     req.onsuccess = function () {
       ok(true, "Deleted the database");
       next();
     };
     req.onerror = onFailure;
   },
   function () {
--- a/dom/system/gonk/AutoMounterSetting.cpp
+++ b/dom/system/gonk/AutoMounterSetting.cpp
@@ -73,17 +73,17 @@ AutoMounterSetting::AutoMounterSetting()
   // becomes unlocked and changes ums.mode appropriately.
   nsCOMPtr<nsISettingsService> settingsService =
     do_GetService("@mozilla.org/settingsService;1");
   if (!settingsService) {
     ERR("Failed to get settingsLock service!");
     return;
   }
   nsCOMPtr<nsISettingsServiceLock> lock;
-  settingsService->GetLock(getter_AddRefs(lock));
+  settingsService->CreateLock(getter_AddRefs(lock));
   nsCOMPtr<nsISettingsServiceCallback> callback = new SettingsServiceCallback();
   lock->Set(UMS_MODE, INT_TO_JSVAL(AUTOMOUNTER_DISABLE), callback, nullptr);
 }
 
 AutoMounterSetting::~AutoMounterSetting()
 {
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -111,17 +111,17 @@ function NetworkManager() {
   this._tetheringInterface[TETHERING_TYPE_USB] = {externalInterface: DEFAULT_3G_INTERFACE_NAME,
                                                   internalInterface: DEFAULT_USB_INTERFACE_NAME};
   this._tetheringInterface[TETHERING_TYPE_WIFI] = {externalInterface: DEFAULT_3G_INTERFACE_NAME,
                                                    internalInterface: DEFAULT_WIFI_INTERFACE_NAME};
 
   this.tetheringSettings[SETTINGS_WIFI_ENABLED] = false;
   this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
 
-  let settingsLock = gSettingsService.getLock();
+  let settingsLock = gSettingsService.createLock();
   // Read wifi tethering data from settings DB.
   settingsLock.get(SETTINGS_WIFI_SSID, this);
   settingsLock.get(SETTINGS_WIFI_SECURITY_TYPE, this);
   settingsLock.get(SETTINGS_WIFI_SECURITY_PASSWORD, this);
   settingsLock.get(SETTINGS_WIFI_IP, this);
   settingsLock.get(SETTINGS_WIFI_PREFIX, this);
   settingsLock.get(SETTINGS_WIFI_DHCPSERVER_STARTIP, this);
   settingsLock.get(SETTINGS_WIFI_DHCPSERVER_ENDIP, this);
@@ -745,17 +745,17 @@ NetworkManager.prototype = {
   },
 
   wifiTetheringResultReport: function wifiTetheringResultReport(data) {
     let code = data.resultCode;
     let reason = data.resultReason;
     let enable = data.enable;
     let enableString = enable ? "Enable" : "Disable";
     let unload = data.unload;
-    let settingsLock = gSettingsService.getLock();
+    let settingsLock = gSettingsService.createLock();
 
     debug(enableString + " Wifi tethering result: Code " + code + " reason " + reason);
     // Unload wifi driver when
     // 1. We have sent disable tethering commands to netd and switch wifi to station mode.
     // 2. We fail to enable wifi tethering.
     if (unload) {
       gWifi.setWifiTethering(false, this.setWifiTetheringDisabledResult.bind(this));
     }
@@ -767,17 +767,17 @@ NetworkManager.prototype = {
     }
   },
 
   usbTetheringResultReport: function usbTetheringResultReport(data) {
     let code = data.resultCode;
     let reason = data.resultReason;
     let enable = data.enable;
     let enableString = enable ? "Enable" : "Disable";
-    let settingsLock = gSettingsService.getLock();
+    let settingsLock = gSettingsService.createLock();
 
     debug(enableString + " USB tethering result: Code " + code + " reason " + reason);
     // Disable tethering settings when fail to enable it.
     if (code < NETD_COMMAND_OKAY && code >= NETD_COMMAND_ERROR) {
       this.tetheringSettings[SETTINGS_USB_ENABLED] = false;
       settingsLock.set("tethering.usb.enabled", false, null);
     }
   }
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -178,26 +178,26 @@ function RadioInterfaceLayer() {
                      cell: null,
                      type: null,
                      signalStrength: null,
                      relSignalStrength: null},
   };
 
   // Read the 'ril.radio.disabled' setting in order to start with a known
   // value at boot time.
-  gSettingsService.getLock().get("ril.radio.disabled", this);
+  gSettingsService.createLock().get("ril.radio.disabled", this);
 
   // Read the APN data form the setting DB.
-  gSettingsService.getLock().get("ril.data.apn", this);
-  gSettingsService.getLock().get("ril.data.user", this);
-  gSettingsService.getLock().get("ril.data.passwd", this);
-  gSettingsService.getLock().get("ril.data.httpProxyHost", this);
-  gSettingsService.getLock().get("ril.data.httpProxyPort", this);
-  gSettingsService.getLock().get("ril.data.roaming_enabled", this);
-  gSettingsService.getLock().get("ril.data.enabled", this);
+  gSettingsService.createLock().get("ril.data.apn", this);
+  gSettingsService.createLock().get("ril.data.user", this);
+  gSettingsService.createLock().get("ril.data.passwd", this);
+  gSettingsService.createLock().get("ril.data.httpProxyHost", this);
+  gSettingsService.createLock().get("ril.data.httpProxyPort", this);
+  gSettingsService.createLock().get("ril.data.roaming_enabled", this);
+  gSettingsService.createLock().get("ril.data.enabled", this);
   this._dataCallSettingsToRead = ["ril.data.enabled",
                                   "ril.data.roaming_enabled",
                                   "ril.data.apn",
                                   "ril.data.user",
                                   "ril.data.passwd",
                                   "ril.data.httpProxyHost",
                                   "ril.data.httpProxyPort"];
 
--- a/dom/system/gonk/TimeSetting.cpp
+++ b/dom/system/gonk/TimeSetting.cpp
@@ -49,17 +49,17 @@ public:
       // Set the settings based on the current system timezone.
       nsCOMPtr<nsISettingsServiceLock> lock;
       nsCOMPtr<nsISettingsService> settingsService =
         do_GetService("@mozilla.org/settingsService;1");
       if (!settingsService) {
         ERR("Failed to get settingsLock service!");
         return NS_OK;
       }
-      settingsService->GetLock(getter_AddRefs(lock));
+      settingsService->CreateLock(getter_AddRefs(lock));
       lock->Set(TIME_TIMEZONE, STRING_TO_JSVAL(jsStr), nullptr, nullptr);
       return NS_OK;
     }
 
     // Set the system timezone based on the current settings.
     if (aResult.isString()) {
       return TimeSetting::SetTimezone(aResult, aContext);
     }
@@ -94,17 +94,17 @@ TimeSetting::TimeSetting()
   // value at boot time. The handle() will be called after reading.
   nsCOMPtr<nsISettingsServiceLock> lock;
   nsCOMPtr<nsISettingsService> settingsService =
     do_GetService("@mozilla.org/settingsService;1");
   if (!settingsService) {
     ERR("Failed to get settingsLock service!");
     return;
   }
-  settingsService->GetLock(getter_AddRefs(lock));
+  settingsService->CreateLock(getter_AddRefs(lock));
   nsCOMPtr<nsISettingsServiceCallback> callback = new InitTimezoneCb();
   lock->Get(TIME_TIMEZONE, callback);
 }
 
 nsresult TimeSetting::SetTimezone(const JS::Value &aValue, JSContext *aContext)
 {
   // Convert the JS value to a nsCString type.
   nsDependentJSString valueStr;
--- a/dom/tests/mochitest/geolocation/test_mozsettings.html
+++ b/dom/tests/mochitest/geolocation/test_mozsettings.html
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function toggleGeolocationSetting(value, callback) {
   var mozSettings = window.navigator.mozSettings;
-  var lock = mozSettings.getLock();
+  var lock = mozSettings.createLock();
 
   var geoenabled = {"geolocation.enabled": value};
 
   req = lock.set(geoenabled);
   req.onsuccess = function () {
     ok(true, "set done");
     callback();
   }
--- a/dom/tests/mochitest/geolocation/test_mozsettingsWatch.html
+++ b/dom/tests/mochitest/geolocation/test_mozsettingsWatch.html
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function toggleGeolocationSetting(value, callback) {
   var mozSettings = window.navigator.mozSettings;
-  var lock = mozSettings.getLock();
+  var lock = mozSettings.createLock();
 
   var geoenabled = {"geolocation.enabled": value};
 
   req = lock.set(geoenabled);
   req.onsuccess = function () {
     ok(true, "set done");
     callback();
   }
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -1730,17 +1730,17 @@ function WifiWorker() {
         aResult = true;
       self.setWifiEnabled({enabled: aResult});
     },
     handleError: function handleError(aErrorMessage) {
       debug("Error reading the 'wifi.enabled' setting. Default to wifi on.");
       self.setWifiEnabled({enabled: true});
     },
   };
-  gSettingsService.getLock().get("wifi.enabled", initWifiEnabledCb);
+  gSettingsService.createLock().get("wifi.enabled", initWifiEnabledCb);
 }
 
 function translateState(state) {
   switch (state) {
     case "INTERFACE_DISABLED":
     case "INACTIVE":
     case "SCANNING":
     case "DISCONNECTED":
@@ -2313,17 +2313,17 @@ WifiWorker.prototype = {
   _updateWifiSetting: function(enabled) {
     // This is used to update the setting value, whenever the
     // WifiManager.enabled is re-assigned based on supplicant
     // connection/lost/failed.
     //
     // To avoid WifiWorker setting the wifi again, we mark the
     // "fromInternalSetting" so WifiWorker won't deal with such
     // an internal "mozsettings-changed" event when receiving it.
-    gSettingsService.getLock().set(
+    gSettingsService.createLock().set(
       "wifi.enabled", enabled, null, "fromInternalSetting");
   },
 
   // nsIObserver implementation
   observe: function observe(subject, topic, data) {
     // Note that this function gets called for any and all settings changes,
     // so we need to carefully check if we have the one we're interested in.
     // The string we're interested in will be a JSON string that looks like:
--- a/xpcom/tests/TestSettingsAPI.cpp
+++ b/xpcom/tests/TestSettingsAPI.cpp
@@ -231,36 +231,36 @@ TestSettingsAPI()
   nsCOMPtr<nsISettingsServiceCallback> cb5 = new SettingsServiceCallback();
   nsCOMPtr<nsISettingsServiceCallback> cb6 = new SettingsServiceCallback();
   nsCOMPtr<nsISettingsServiceCallback> cb7 = new SettingsServiceCallback();
   nsCOMPtr<nsISettingsServiceCallback> cb8 = new SettingsServiceCallback();
   nsCOMPtr<nsISettingsServiceCallback> cb9 = new SettingsServiceCallback();
 
   nsCOMPtr<nsISettingsService> iss = do_GetService("@mozilla.org/settingsService;1");
   nsCOMPtr<nsISettingsServiceLock> lock;
-  iss->GetLock(getter_AddRefs(lock));
+  iss->CreateLock(getter_AddRefs(lock));
 
   nsCOMPtr<nsISettingsServiceLock> lock1;
-  iss->GetLock(getter_AddRefs(lock1));
+  iss->CreateLock(getter_AddRefs(lock1));
 
   lock->Set("asdf", BOOLEAN_TO_JSVAL(true), cb0, nullptr);
   lock1->Get("asdf", cb1);
   lock->Get("asdf", cb2);
   lock->Set("asdf", BOOLEAN_TO_JSVAL(false), cb3, nullptr);
   lock->Get("asdf", cb4);
   lock->Set("int", INT_TO_JSVAL(9), cb5, nullptr);
   lock->Get("int", cb6);
   lock->Set("doub", DOUBLE_TO_JSVAL(9.4), cb7, nullptr);
   lock->Get("doub", cb8);
   lock1->Get("asdfxxx", cb9);
 
   // The followings test if the observer can receive correct settings.
   // Case #1 won't carry any message; case #2 will carry TEST_OBSERVER_MESSAGE.
   nsCOMPtr<nsISettingsServiceLock> lock2;
-    iss->GetLock(getter_AddRefs(lock2));
+    iss->CreateLock(getter_AddRefs(lock2));
   lock2->Set(TEST_OBSERVER_KEY,
              BOOLEAN_TO_JSVAL(TEST_OBSERVER_VALUE),
              nullptr, nullptr);
   lock2->Set(TEST_OBSERVER_KEY,
              BOOLEAN_TO_JSVAL(TEST_OBSERVER_VALUE),
              nullptr, TEST_OBSERVER_MESSAGE);
 
   return NS_OK;