mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 04:05:32 +00:00
761a458cda
There are several places in the WebExtensions framework where we currently need to repeatedly serialize and deserialize structured clone data as it passes through message managers, which can lead to significant performance issues. This helper class lets us serialize a value directly from the source extension context into an opaque blob, and then directly deserialize it into the target context on the other end, with no X-ray overhead or clones into privileged scopes in-between. MozReview-Commit-ID: 4QzHi89onxc --HG-- extra : rebase_source : 2ec196ca9ce9be90b7eadf136c938373ac7d3fdd
28 lines
980 B
Plaintext
28 lines
980 B
Plaintext
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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/.
|
|
*/
|
|
|
|
/**
|
|
* A holder for structured-clonable data which can itself be cloned with
|
|
* little overhead, and deserialized into an arbitrary global.
|
|
*/
|
|
[ChromeOnly, Exposed=(Window,System,Worker),
|
|
/**
|
|
* Serializes the given value to an opaque structured clone blob, and
|
|
* returns the result.
|
|
*
|
|
* The serialization happens in the compartment of the given global or, if no
|
|
* global is provided, the compartment of the data value.
|
|
*/
|
|
Constructor(any data, optional object? global = null)]
|
|
interface StructuredCloneHolder {
|
|
/**
|
|
* Deserializes the structured clone data in the scope of the given global,
|
|
* and returns the result.
|
|
*/
|
|
[Throws]
|
|
any deserialize(object global);
|
|
};
|