remove server lock wrapper; change local lock to work with service.js local locking api
remove server lock wrapper; change local lock to work with service.js local locking api
--- a/services/sync/modules/wrap.js
+++ b/services/sync/modules/wrap.js
@@ -38,17 +38,16 @@ const EXPORTED_SYMBOLS = ['Wrap'];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://weave/log4moz.js");
-Cu.import("resource://weave/dav.js");
Cu.import("resource://weave/async.js");
Cu.import("resource://weave/faultTolerance.js");
Function.prototype.async = Async.sugar;
/*
* Wrapper utility functions
*
@@ -105,81 +104,42 @@ let Wrap = {
}
self.done(ret);
};
},
// NOTE: see notify, this works the same way. they can be
// chained together as well.
- lock: function WeaveSync_lock(method /* , arg1, arg2, ..., argN */) {
- let savedMethod = method;
- let savedArgs = Array.prototype.slice.call(arguments, 1);
-
- return function WeaveLockWrapper( /* argN+1, argN+2, ... */) {
- let self = yield;
- let ret;
- let args = Array.prototype.slice.call(arguments);
-
- if (!this._loggedIn)
- throw "Could not acquire lock (not logged in)";
- if (DAV.locked)
- throw "Could not acquire lock (lock already held)";
-
- let locked = yield DAV.lock.async(DAV, self.cb);
- if (!locked)
- throw "Could not acquire lock";
-
- this._os.notifyObservers(null, this._osPrefix + "lock:acquired", "");
-
- try {
- args = savedArgs.concat(args);
- args.unshift(this, savedMethod, self.cb);
- ret = yield Async.run.apply(Async, args);
-
- } catch (e) {
- throw e;
-
- } finally {
- yield DAV.unlock.async(DAV, self.cb);
- this._os.notifyObservers(null, this._osPrefix + "lock:released", "");
- }
-
- self.done(ret);
- };
- },
-
- // NOTE: see notify, this works the same way. they can be
- // chained together as well.
localLock: function WeaveSync_localLock(method /* , arg1, arg2, ..., argN */) {
let savedMethod = method;
let savedArgs = Array.prototype.slice.call(arguments, 1);
return function WeaveLocalLockWrapper(/* argN+1, argN+2, ... */) {
let self = yield;
let ret;
let args = Array.prototype.slice.call(arguments);
- if (DAV.locked)
+ let ret = this.lock();
+ if (!ret)
throw "Could not acquire lock";
- DAV.allowLock = false;
this._os.notifyObservers(null,
this._osPrefix + "local-lock:acquired", "");
try {
args = savedArgs.concat(args);
args.unshift(this, savedMethod, self.cb);
ret = yield Async.run.apply(Async, args);
} catch (e) {
throw e;
} finally {
- DAV.allowLock = true;
+ this.unlock();
this._os.notifyObservers(null,
this._osPrefix + "local-lock:released", "");
}
self.done(ret);
};
},