зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-cental into mozilla-inbound
This commit is contained in:
Коммит
395197733f
|
@ -121,9 +121,17 @@ SettingsListener.observe('language.current', 'en-US', function(value) {
|
|||
Ci.nsIPrefLocalizedString).data;
|
||||
} catch(e) {}
|
||||
|
||||
// Bug 830782 - Homescreen is in English instead of selected locale after
|
||||
// the first run experience.
|
||||
// In order to ensure the current intl value is reflected on the child
|
||||
// process let's always write a user value, even if this one match the
|
||||
// current localized pref value.
|
||||
if (!((new RegExp('^' + value + '[^a-z-_] *[,;]?', 'i')).test(intl))) {
|
||||
Services.prefs.setCharPref(prefName, value + ', ' + intl);
|
||||
value = value + ', ' + intl;
|
||||
} else {
|
||||
value = intl;
|
||||
}
|
||||
Services.prefs.setCharPref(prefName, value);
|
||||
|
||||
if (shell.hasStarted() == false) {
|
||||
shell.start();
|
||||
|
|
|
@ -23,7 +23,10 @@ let gSyncUI = {
|
|||
init: function SUI_init() {
|
||||
// Proceed to set up the UI if Sync has already started up.
|
||||
// Otherwise we'll do it when Sync is firing up.
|
||||
if (Weave.Status.ready) {
|
||||
let xps = Components.classes["@mozilla.org/weave/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject;
|
||||
if (xps.ready) {
|
||||
this.initUI();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,37 @@ let gSyncPane = {
|
|||
},
|
||||
|
||||
init: function () {
|
||||
// If the Service hasn't finished initializing, wait for it.
|
||||
let xps = Components.classes["@mozilla.org/weave/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject;
|
||||
|
||||
if (xps.ready) {
|
||||
this._init();
|
||||
return;
|
||||
}
|
||||
|
||||
let onUnload = function () {
|
||||
window.removeEventListener("unload", onUnload, false);
|
||||
try {
|
||||
Services.obs.removeObserver(onReady, "weave:service:ready");
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
let onReady = function () {
|
||||
Services.obs.removeObserver(onReady, "weave:service:ready");
|
||||
window.removeEventListener("unload", onUnload, false);
|
||||
this._init();
|
||||
}.bind(this);
|
||||
|
||||
|
||||
Services.obs.addObserver(onReady, "weave:service:ready", false);
|
||||
window.addEventListener("unload", onUnload, false);
|
||||
|
||||
xps.ensureLoaded();
|
||||
},
|
||||
|
||||
_init: function () {
|
||||
let topics = ["weave:service:login:error",
|
||||
"weave:service:login:finish",
|
||||
"weave:service:start-over",
|
||||
|
|
|
@ -34,6 +34,36 @@ let gSyncPane = {
|
|||
},
|
||||
|
||||
init: function () {
|
||||
// If the Service hasn't finished initializing, wait for it.
|
||||
let xps = Components.classes["@mozilla.org/weave/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject;
|
||||
|
||||
if (xps.ready) {
|
||||
this._init();
|
||||
return;
|
||||
}
|
||||
|
||||
let onUnload = function () {
|
||||
window.removeEventListener("unload", onUnload, false);
|
||||
try {
|
||||
Services.obs.removeObserver(onReady, "weave:service:ready");
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
let onReady = function () {
|
||||
Services.obs.removeObserver(onReady, "weave:service:ready");
|
||||
window.removeEventListener("unload", onUnload, false);
|
||||
this._init();
|
||||
}.bind(this);
|
||||
|
||||
Services.obs.addObserver(onReady, "weave:service:ready", false);
|
||||
window.addEventListener("unload", onUnload, false);
|
||||
|
||||
xps.ensureLoaded();
|
||||
},
|
||||
|
||||
_init: function () {
|
||||
let topics = ["weave:service:login:error",
|
||||
"weave:service:login:finish",
|
||||
"weave:service:start-over",
|
||||
|
|
|
@ -149,6 +149,8 @@ static PRTime sCCLockedOutTime;
|
|||
static JS::GCSliceCallback sPrevGCSliceCallback;
|
||||
static js::AnalysisPurgeCallback sPrevAnalysisPurgeCallback;
|
||||
|
||||
static bool sHasRunGC;
|
||||
|
||||
// The number of currently pending document loads. This count isn't
|
||||
// guaranteed to always reflect reality and can't easily as we don't
|
||||
// have an easy place to know when a load ends or is interrupted in
|
||||
|
@ -3080,7 +3082,7 @@ nsJSContext::PokeShrinkGCBuffers()
|
|||
void
|
||||
nsJSContext::MaybePokeCC()
|
||||
{
|
||||
if (sCCTimer || sShuttingDown) {
|
||||
if (sCCTimer || sShuttingDown || !sHasRunGC) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3239,6 +3241,7 @@ DOMGCSliceCallback(JSRuntime *aRt, JS::GCProgress aProgress, const JS::GCDescrip
|
|||
sCCollectedWaitingForGC = 0;
|
||||
sCleanupsSinceLastGC = 0;
|
||||
sNeedsFullCC = true;
|
||||
sHasRunGC = true;
|
||||
nsJSContext::MaybePokeCC();
|
||||
|
||||
if (aDesc.isCompartment) {
|
||||
|
@ -3358,6 +3361,7 @@ nsJSRuntime::Startup()
|
|||
sCCLockedOut = false;
|
||||
sCCLockedOutTime = 0;
|
||||
sLastCCEndTime = 0;
|
||||
sHasRunGC = false;
|
||||
sPendingLoadCount = 0;
|
||||
sLoadingInProgress = false;
|
||||
sCCollectedWaitingForGC = 0;
|
||||
|
|
|
@ -14,9 +14,28 @@ let WeaveGlue = {
|
|||
_progressMax: null,
|
||||
|
||||
init: function init() {
|
||||
if (this._bundle)
|
||||
if (this._bundle) {
|
||||
return;
|
||||
}
|
||||
|
||||
let service = Components.classes["@mozilla.org/weave/service;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject;
|
||||
|
||||
if (service.ready) {
|
||||
this._init();
|
||||
return;
|
||||
}
|
||||
|
||||
Services.obs.addObserver(function onReady() {
|
||||
Services.obs.removeObserver(onReady, "weave:service:ready");
|
||||
this._init();
|
||||
}.bind(this), "weave:service:ready", false);
|
||||
|
||||
service.ensureLoaded();
|
||||
},
|
||||
|
||||
_init: function () {
|
||||
this._bundle = Services.strings.createBundle("chrome://browser/locale/sync.properties");
|
||||
this._msg = document.getElementById("prefs-messages");
|
||||
|
||||
|
|
|
@ -10,17 +10,21 @@ VPATH = @srcdir@
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
modules := \
|
||||
async.js \
|
||||
log4moz.js \
|
||||
observers.js \
|
||||
preferences.js \
|
||||
rest.js \
|
||||
storageservice.js \
|
||||
stringbundle.js \
|
||||
tokenserverclient.js \
|
||||
utils.js \
|
||||
$(NULL)
|
||||
|
||||
pp_modules := \
|
||||
async.js \
|
||||
bagheeraclient.js \
|
||||
observers.js \
|
||||
rest.js \
|
||||
$(NULL)
|
||||
|
||||
testing_modules := \
|
||||
aitcserver.js \
|
||||
bagheeraserver.js \
|
||||
|
@ -44,7 +48,7 @@ INSTALL_TARGETS += MODULES
|
|||
TESTING_JS_MODULES := $(addprefix modules-testing/,$(testing_modules))
|
||||
TESTING_JS_MODULE_DIR := services-common
|
||||
|
||||
PP_JS_MODULES := bagheeraclient.js
|
||||
PP_JS_MODULES := $(pp_modules)
|
||||
PP_JS_MODULES_PATH = $(FINAL_TARGET)/modules/services-common
|
||||
PP_TARGETS += PP_JS_MODULES
|
||||
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MERGED_COMPARTMENT
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["Async"];
|
||||
|
||||
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
|
||||
|
||||
#endif
|
||||
|
||||
// Constants for makeSyncCallback, waitForSyncCallback.
|
||||
const CB_READY = {};
|
||||
const CB_COMPLETE = {};
|
||||
|
|
|
@ -20,11 +20,11 @@ this.EXPORTED_SYMBOLS = [
|
|||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://services-common/rest.js");
|
||||
#endif
|
||||
|
||||
Cu.import("resource://gre/modules/commonjs/promise/core.js");
|
||||
Cu.import("resource://services-common/log4moz.js");
|
||||
Cu.import("resource://services-common/rest.js");
|
||||
Cu.import("resource://services-common/utils.js");
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MERGED_COMPARTMENT
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["Observers"];
|
||||
|
||||
const Cc = Components.classes;
|
||||
|
@ -9,6 +11,8 @@ const Ci = Components.interfaces;
|
|||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
|
||||
#endif
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MERGED_COMPARTMENT
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
|
@ -10,13 +12,17 @@ this.EXPORTED_SYMBOLS = [
|
|||
"TokenAuthenticatedRESTRequest"
|
||||
];
|
||||
|
||||
#endif
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://services-crypto/utils.js");
|
||||
Cu.import("resource://services-common/log4moz.js");
|
||||
Cu.import("resource://services-common/preferences.js");
|
||||
Cu.import("resource://services-common/utils.js");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CryptoUtils",
|
||||
"resource://services-crypto/utils.js");
|
||||
|
||||
const Prefs = new Preferences("services.common.rest.");
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://services-common/observers.js");
|
||||
Cu.import("resource://services-common/preferences.js");
|
||||
Cu.import("resource://services-common/utils.js");
|
||||
|
||||
|
@ -257,6 +256,8 @@ this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DataReportingService]);
|
|||
|
||||
#define MERGED_COMPARTMENT
|
||||
|
||||
#include ../common/observers.js
|
||||
;
|
||||
#include policy.jsm
|
||||
;
|
||||
#include sessions.jsm
|
||||
|
|
|
@ -24,6 +24,8 @@ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
|
|||
// issue.
|
||||
#define MERGED_COMPARTMENT
|
||||
|
||||
#include ../common/async.js
|
||||
;
|
||||
#include ../common/bagheeraclient.js
|
||||
;
|
||||
#include ../metrics/Metrics.jsm
|
||||
|
|
|
@ -14,9 +14,9 @@ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
|
|||
|
||||
Cu.import("resource://gre/modules/Metrics.jsm");
|
||||
Cu.import("resource://services-common/bagheeraclient.js");
|
||||
Cu.import("resource://services-common/async.js");
|
||||
#endif
|
||||
|
||||
Cu.import("resource://services-common/async.js");
|
||||
Cu.import("resource://services-common/log4moz.js");
|
||||
Cu.import("resource://services-common/preferences.js");
|
||||
Cu.import("resource://services-common/utils.js");
|
||||
|
|
|
@ -10,8 +10,46 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
const SYNC_PREFS_BRANCH = "services.sync.";
|
||||
|
||||
|
||||
/**
|
||||
* Sync's XPCOM service.
|
||||
*
|
||||
* It is named "Weave" for historical reasons.
|
||||
*
|
||||
* It's worth noting how Sync is lazily loaded. We register a timer that
|
||||
* loads Sync a few seconds after app startup. This is so Sync does not
|
||||
* adversely affect application start time.
|
||||
*
|
||||
* If Sync is not configured, no extra Sync code is loaded. If an
|
||||
* external component (say the UI) needs to interact with Sync, it
|
||||
* should do something like the following:
|
||||
*
|
||||
* // 1. Grab a handle to the Sync XPCOM service.
|
||||
* let service = Cc["@mozilla.org/weave/service;1"]
|
||||
* .getService(Components.interfaces.nsISupports)
|
||||
* .wrappedJSObject;
|
||||
*
|
||||
* // 2. Check if the service has been initialized.
|
||||
* if (service.ready) {
|
||||
* // You are free to interact with "Weave." objects.
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* // 3. Install "ready" listener.
|
||||
* Services.obs.addObserver(function onReady() {
|
||||
* Services.obs.removeObserver(onReady, "weave:service:ready");
|
||||
*
|
||||
* // You are free to interact with "Weave." objects.
|
||||
* }, "weave:service:ready", false);
|
||||
*
|
||||
* // 4. Trigger loading of Sync.
|
||||
* service.ensureLoaded();
|
||||
*/
|
||||
function WeaveService() {
|
||||
this.wrappedJSObject = this;
|
||||
this.ready = false;
|
||||
}
|
||||
WeaveService.prototype = {
|
||||
classID: Components.ID("{74b89fb0-f200-4ae8-a3ec-dd164117f6de}"),
|
||||
|
@ -19,7 +57,14 @@ WeaveService.prototype = {
|
|||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
observe: function BSS__observe(subject, topic, data) {
|
||||
ensureLoaded: function () {
|
||||
Components.utils.import("resource://services-sync/main.js");
|
||||
|
||||
// Side-effect of accessing the service is that it is instantiated.
|
||||
Weave.Service;
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "app-startup":
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
|
@ -32,9 +77,21 @@ WeaveService.prototype = {
|
|||
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
this.timer.initWithCallback({
|
||||
notify: function() {
|
||||
Cu.import("resource://services-sync/main.js");
|
||||
if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED)
|
||||
Weave.Service;
|
||||
// We only load more if it looks like Sync is configured.
|
||||
let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
|
||||
|
||||
if (!prefs.prefHasUserValue("username")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We have a username. So, do a more thorough check. This will
|
||||
// import a number of modules and thus increase memory
|
||||
// accordingly. We could potentially copy code performed by
|
||||
// this check into this file if our above code is yielding too
|
||||
// many false positives.
|
||||
if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED) {
|
||||
this.ensureLoaded();
|
||||
}
|
||||
}
|
||||
}, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
break;
|
||||
|
|
|
@ -8,11 +8,18 @@ this.EXPORTED_SYMBOLS = ["IdentityManager"];
|
|||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://services-sync/constants.js");
|
||||
Cu.import("resource://services-sync/keys.js");
|
||||
Cu.import("resource://services-common/log4moz.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
||||
// Lazy import to prevent unnecessary load on startup.
|
||||
for (let symbol of ["BulkKeyBundle", "SyncKeyBundle"]) {
|
||||
XPCOMUtils.defineLazyModuleGetter(this, symbol,
|
||||
"resource://services-sync/keys.js",
|
||||
symbol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages identity and authentication for Sync.
|
||||
*
|
||||
|
|
|
@ -362,6 +362,14 @@ Sync11Service.prototype = {
|
|||
// registering an observer.
|
||||
Utils.nextTick(function onNextTick() {
|
||||
this.status.ready = true;
|
||||
|
||||
// UI code uses the flag on the XPCOM service so it doesn't have
|
||||
// to load a bunch of modules.
|
||||
let xps = Cc["@mozilla.org/weave/service;1"]
|
||||
.getService(Ci.nsISupports)
|
||||
.wrappedJSObject;
|
||||
xps.ready = true;
|
||||
|
||||
Svc.Obs.notify("weave:service:ready");
|
||||
}.bind(this));
|
||||
},
|
||||
|
|
|
@ -30,9 +30,16 @@ function run_test() {
|
|||
|
||||
_("Observers are notified of startup");
|
||||
do_test_pending();
|
||||
|
||||
let xps = Cc["@mozilla.org/weave/service;1"]
|
||||
.getService(Ci.nsISupports)
|
||||
.wrappedJSObject;
|
||||
|
||||
do_check_false(Service.status.ready);
|
||||
do_check_false(xps.ready);
|
||||
Observers.add("weave:service:ready", function (subject, data) {
|
||||
do_check_true(Service.status.ready);
|
||||
do_check_true(xps.ready);
|
||||
|
||||
// Clean up.
|
||||
Svc.Prefs.resetBranch("");
|
||||
|
|
Загрузка…
Ссылка в новой задаче