mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 03:05:34 +00:00
Merged
This commit is contained in:
commit
667ff6a599
@ -60,7 +60,14 @@ else
|
||||
cxx = cl
|
||||
so = dll
|
||||
else
|
||||
$(error Sorry, your os is unknown/unsupported: $(sys))
|
||||
ifeq ($(sys), MINGW32_NT-5.1)
|
||||
os = WINNT
|
||||
compiler = msvc
|
||||
cxx = cl
|
||||
so = dll
|
||||
else
|
||||
$(error Sorry, your os is unknown/unsupported: $(sys))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -1,3 +1,4 @@
|
||||
status.wait = Waiting for current sync to finish...
|
||||
status.active = Syncing with Weave...
|
||||
status.success = Sync succeeded.
|
||||
status.error = Sync failed.
|
||||
|
@ -42,7 +42,7 @@ const EXPORTED_SYMBOLS = ['WEAVE_VERSION', 'STORAGE_FORMAT_VERSION',
|
||||
'PERMS_FILE', 'PERMS_PASSFILE', 'PERMS_DIRECTORY',
|
||||
'ONE_BYTE', 'ONE_KILOBYTE', 'ONE_MEGABYTE'];
|
||||
|
||||
const WEAVE_VERSION = "0.2.0";
|
||||
const WEAVE_VERSION = "0.2.2";
|
||||
const STORAGE_FORMAT_VERSION = 3;
|
||||
const ENGINE_STORAGE_FORMAT_VERSION = 3;
|
||||
|
||||
|
@ -120,16 +120,14 @@ DAVCollection.prototype = {
|
||||
this._log.debug(op + " request for " + (path? path : 'root folder'));
|
||||
|
||||
if (!path || path[0] != '/')
|
||||
// if it's a relative path, (no slash), prepend default prefix
|
||||
path = this._defaultPrefix + path;
|
||||
path = this._defaultPrefix + path; // if relative: prepend default prefix
|
||||
else
|
||||
path = path.slice(1); // if absolute path, remove leading slash
|
||||
path = path.slice(1); // if absolute: remove leading slash
|
||||
// path at this point should have no leading slash.
|
||||
|
||||
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||
|
||||
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
|
||||
createInstance(Ci.nsIXMLHttpRequest);
|
||||
let xhrCb = self.cb;
|
||||
|
||||
request.onload = new Utils.EventListener(xhrCb, "load");
|
||||
request.onerror = new Utils.EventListener(xhrCb, "error");
|
||||
request.mozBackgroundRequest = true;
|
||||
@ -354,52 +352,49 @@ DAVCollection.prototype = {
|
||||
|
||||
lock: function DC_lock() {
|
||||
let self = yield;
|
||||
let resp;
|
||||
|
||||
this._log.trace("Acquiring lock");
|
||||
if (!this._allowLock)
|
||||
throw {message: "Cannot acquire lock (internal lock)"};
|
||||
this._allowLock = false;
|
||||
try {
|
||||
this._log.trace("Acquiring lock");
|
||||
|
||||
if (DAVLocks['default']) {
|
||||
this._log.debug("Lock called, but we already hold a token");
|
||||
if (this.locked) {
|
||||
this._log.debug("Lock called, but we are already locked");
|
||||
return;
|
||||
}
|
||||
this._allowLock = false;
|
||||
|
||||
resp = yield this.LOCK("lock",
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
|
||||
"<D:lockinfo xmlns:D=\"DAV:\">\n" +
|
||||
" <D:locktype><D:write/></D:locktype>\n" +
|
||||
" <D:lockscope><D:exclusive/></D:lockscope>\n" +
|
||||
"</D:lockinfo>", self.cb);
|
||||
if (!Utils.checkStatus(resp.status))
|
||||
return;
|
||||
|
||||
let tokens = Utils.xpath(resp.responseXML, '//D:locktoken/D:href');
|
||||
let token = tokens.iterateNext();
|
||||
if (token) {
|
||||
DAVLocks['default'] = {
|
||||
URL: this._baseURL,
|
||||
token: token.textContent
|
||||
};
|
||||
}
|
||||
|
||||
if (DAVLocks['default']) {
|
||||
this._log.trace("Lock acquired");
|
||||
self.done(DAVLocks['default']);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
this._log.error("Could not acquire lock");
|
||||
if (resp.responseText)
|
||||
this._log.error("Server response to LOCK:\n" + resp.responseText);
|
||||
throw e;
|
||||
|
||||
} finally {
|
||||
this._allowLock = true;
|
||||
self.done();
|
||||
return;
|
||||
}
|
||||
|
||||
this.LOCK("lock",
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
|
||||
"<D:lockinfo xmlns:D=\"DAV:\">\n" +
|
||||
" <D:locktype><D:write/></D:locktype>\n" +
|
||||
" <D:lockscope><D:exclusive/></D:lockscope>\n" +
|
||||
"</D:lockinfo>", self.cb);
|
||||
let resp = yield;
|
||||
|
||||
if (resp.status < 200 || resp.status >= 300) {
|
||||
this._allowLock = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let tokens = Utils.xpath(resp.responseXML, '//D:locktoken/D:href');
|
||||
let token = tokens.iterateNext();
|
||||
if (token) {
|
||||
DAVLocks['default'] = {
|
||||
URL: this._baseURL,
|
||||
token: token.textContent
|
||||
};
|
||||
}
|
||||
|
||||
if (!DAVLocks['default']) {
|
||||
this._log.warn("Could not acquire lock");
|
||||
this._allowLock = true;
|
||||
self.done();
|
||||
return;
|
||||
}
|
||||
|
||||
this._log.trace("Lock acquired");
|
||||
this._allowLock = true;
|
||||
|
||||
self.done(DAVLocks['default']);
|
||||
},
|
||||
|
||||
unlock: function DC_unlock() {
|
||||
|
@ -53,16 +53,16 @@ const Cu = Components.utils;
|
||||
// we'll sync it, reset its threshold to the initial value, rinse, and repeat.
|
||||
|
||||
// How long we wait between sync checks.
|
||||
const SCHEDULED_SYNC_INTERVAL = 60 * 1000; // one minute
|
||||
const SCHEDULED_SYNC_INTERVAL = 60 * 1000 * 5; // five minutes
|
||||
|
||||
// INITIAL_THRESHOLD represents the value an engine's score has to exceed
|
||||
// in order for us to sync it the first time we start up (and the first time
|
||||
// we do a sync check after having synced the engine or reset the threshold).
|
||||
const INITIAL_THRESHOLD = 100;
|
||||
const INITIAL_THRESHOLD = 75;
|
||||
|
||||
// THRESHOLD_DECREMENT_STEP is the amount by which we decrement an engine's
|
||||
// threshold each time we do a sync check and don't sync that engine.
|
||||
const THRESHOLD_DECREMENT_STEP = 5;
|
||||
const THRESHOLD_DECREMENT_STEP = 25;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://weave/log4moz.js");
|
||||
@ -173,6 +173,9 @@ WeaveSvc.prototype = {
|
||||
return this.__json;
|
||||
},
|
||||
|
||||
// object for caching public and private keys
|
||||
_keyPair: {},
|
||||
|
||||
// Timer object for automagically syncing
|
||||
_scheduleTimer: null,
|
||||
|
||||
@ -400,23 +403,33 @@ WeaveSvc.prototype = {
|
||||
|
||||
// XXX this kind of replaces _keyCheck
|
||||
// seems like key generation should only happen during setup?
|
||||
DAV.GET("private/privkey", self.cb);
|
||||
let privkeyResp = yield;
|
||||
Utils.ensureStatus(privkeyResp.status,
|
||||
"Could not get private key from server", statuses);
|
||||
|
||||
DAV.GET("public/pubkey", self.cb);
|
||||
let pubkeyResp = yield;
|
||||
Utils.ensureStatus(pubkeyResp.status,
|
||||
"Could not get public key from server", statuses);
|
||||
if (!(this._keyPair['private'] && this._keyPair['public'])) {
|
||||
this._log.info("Fetching keypair from server.");
|
||||
|
||||
if (privkeyResp.status == 404 || pubkeyResp.status == 404) {
|
||||
yield this._generateKeys.async(this, self.cb);
|
||||
return;
|
||||
DAV.GET("private/privkey", self.cb);
|
||||
let privkeyResp = yield;
|
||||
Utils.ensureStatus(privkeyResp.status,
|
||||
"Could not get private key from server", statuses);
|
||||
|
||||
DAV.GET("public/pubkey", self.cb);
|
||||
let pubkeyResp = yield;
|
||||
Utils.ensureStatus(pubkeyResp.status,
|
||||
"Could not get public key from server", statuses);
|
||||
|
||||
if (privkeyResp.status == 404 || pubkeyResp.status == 404) {
|
||||
yield this._generateKeys.async(this, self.cb);
|
||||
return;
|
||||
}
|
||||
|
||||
this._keyPair['private'] = this._json.decode(privkeyResp.responseText);
|
||||
this._keyPair['public'] = this._json.decode(pubkeyResp.responseText);
|
||||
} else {
|
||||
this._log.info("Using cached keypair");
|
||||
}
|
||||
|
||||
let privkeyData = this._json.decode(privkeyResp.responseText);
|
||||
let pubkeyData = this._json.decode(pubkeyResp.responseText);
|
||||
let privkeyData = this._keyPair['private']
|
||||
let pubkeyData = this._keyPair['public'];
|
||||
|
||||
if (!privkeyData || !pubkeyData)
|
||||
throw "Bad keypair JSON";
|
||||
@ -504,9 +517,7 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
|
||||
_onQuitApplication: function WeaveSvc__onQuitApplication() {
|
||||
if (!this.enabled ||
|
||||
!Utils.prefs.getBoolPref("syncOnQuit.enabled") ||
|
||||
!this._loggedIn)
|
||||
if (!this.enabled || !this._loggedIn)
|
||||
return;
|
||||
|
||||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
@ -605,6 +616,7 @@ WeaveSvc.prototype = {
|
||||
this._log.info("Logging out");
|
||||
this._disableSchedule();
|
||||
this._loggedIn = false;
|
||||
this._keyPair = {};
|
||||
ID.get('WeaveID').setTempPassword(null); // clear cached password
|
||||
ID.get('WeaveCryptoID').setTempPassword(null); // and passphrase
|
||||
this._os.notifyObservers(null, "weave:service:logout:success", "");
|
||||
@ -632,6 +644,7 @@ WeaveSvc.prototype = {
|
||||
_serverWipe: function WeaveSvc__serverWipe() {
|
||||
let self = yield;
|
||||
|
||||
this._keyPair = {};
|
||||
DAV.listFiles.async(DAV, self.cb);
|
||||
let names = yield;
|
||||
|
||||
@ -663,6 +676,11 @@ WeaveSvc.prototype = {
|
||||
yield this._notify(engines[i].name + "-engine:sync",
|
||||
this._syncEngine, engines[i]).async(this, self.cb);
|
||||
}
|
||||
|
||||
if (this._syncError) {
|
||||
this._syncError = false;
|
||||
throw "Some engines did not sync correctly";
|
||||
}
|
||||
},
|
||||
|
||||
// The values that engine scores must meet or exceed before we sync them
|
||||
@ -716,6 +734,11 @@ WeaveSvc.prototype = {
|
||||
this._syncThresholds[engine.name] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._syncError) {
|
||||
this._syncError = false;
|
||||
throw "Some engines did not sync correctly";
|
||||
}
|
||||
},
|
||||
|
||||
_syncEngine: function WeaveSvc__syncEngine(engine) {
|
||||
@ -726,6 +749,7 @@ WeaveSvc.prototype = {
|
||||
} catch(e) {
|
||||
this._log.error(Utils.exceptionStr(e));
|
||||
this._log.error(Utils.stackTrace(e));
|
||||
this._syncError = true;
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user