зеркало из https://github.com/mozilla/gecko-dev.git
Bug 989137 - Part 14: Return a promise from Experiments.init(); r=gfritzsche
Upcoming tests will need to wait on init() to finish before running. We now return a promise so these tests don't have to look at internal variables. --HG-- extra : rebase_source : 487645efe419fb3fa3371f85a81e8f3e1ccd9012 extra : amend_source : 3d6bb785e0ecdabcbff1e5bc62ee7dc56cbb7244 extra : histedit_source : 8d12f7e5c47995a408509a85a527bc86f9a76ccb
This commit is contained in:
Родитель
9712b346d6
Коммит
9e7c752bea
|
@ -378,17 +378,22 @@ Experiments.Experiments.prototype = {
|
|||
|
||||
this._registerWithAddonManager();
|
||||
|
||||
this._loadTask = Task.spawn(this._loadFromCache.bind(this));
|
||||
let deferred = Promise.defer();
|
||||
|
||||
this._loadTask = this._loadFromCache();
|
||||
this._loadTask.then(
|
||||
() => {
|
||||
this._log.trace("_loadTask finished ok");
|
||||
this._loadTask = null;
|
||||
this._run();
|
||||
this._run().then(deferred.resolve, deferred.reject);
|
||||
},
|
||||
(e) => {
|
||||
this._log.error("_loadFromCache caught error: " + e);
|
||||
deferred.reject(e);
|
||||
}
|
||||
);
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -818,7 +823,7 @@ Experiments.Experiments.prototype = {
|
|||
/*
|
||||
* Task function, load the cached experiments manifest file from disk.
|
||||
*/
|
||||
_loadFromCache: function*() {
|
||||
_loadFromCache: Task.async(function* () {
|
||||
this._log.trace("_loadFromCache");
|
||||
let path = this._cacheFilePath;
|
||||
try {
|
||||
|
@ -828,7 +833,7 @@ Experiments.Experiments.prototype = {
|
|||
// No cached manifest yet.
|
||||
this._experiments = new Map();
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
_populateFromCache: function (data) {
|
||||
this._log.trace("populateFromCache() - data: " + JSON.stringify(data));
|
||||
|
|
Загрузка…
Ссылка в новой задаче