Bug 1381687: Store and transfer schema JSON in structured clone blobs. r=aswan (not a CLOSED TREE)

MozReview-Commit-ID: FMSbSB1hC3F

--HG--
extra : rebase_source : 73acb9e276fa9cee52c000eae1149b18353736bd
extra : amend_source : 705d22ecd38b10f64009f596f0936673fe054ba0
This commit is contained in:
Kris Maglione 2017-07-17 15:33:54 -07:00
Родитель ac99c20eef
Коммит 6bec989e12
1 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -67,6 +67,12 @@ function readJSON(url) {
});
}
async function readJSONAndBlobbify(url) {
let json = await readJSON(url);
return new StructuredCloneHolder(json);
}
/**
* Defines a lazy getter for the given property on the given object. Any
* security wrappers are waived on the object before the property is
@ -2630,9 +2636,9 @@ this.Schemas = {
value: new Namespace("", []),
});
for (let json of this.schemaJSON.values()) {
for (let blob of this.schemaJSON.values()) {
try {
this.loadSchema(json);
this.loadSchema(blob.deserialize(global));
} catch (e) {
Cu.reportError(e);
}
@ -2659,13 +2665,13 @@ this.Schemas = {
return this._loadCachedSchemasPromise;
},
addSchema(url, json) {
this.schemaJSON.set(url, json);
addSchema(url, schema) {
this.schemaJSON.set(url, schema);
let data = Services.ppmm.initialProcessData;
data["Extension:Schemas"] = this.schemaJSON;
Services.ppmm.broadcastAsyncMessage("Schema:Add", {url, schema: json});
Services.ppmm.broadcastAsyncMessage("Schema:Add", {url, schema});
this.flushSchemas();
},
@ -2677,11 +2683,11 @@ this.Schemas = {
let schemaCache = await this.loadCachedSchemas();
let json = (schemaCache.get(url) ||
await StartupCache.schemas.get(url, readJSON));
let blob = (schemaCache.get(url) ||
await StartupCache.schemas.get(url, readJSONAndBlobbify));
if (!this.schemaJSON.has(url)) {
this.addSchema(url, json);
this.addSchema(url, blob);
}
},