Bug 1622949 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

In bug 1596322, we're adding a scriptable interface that takes an `in nsIPropertyBag` parameter, with primitive (number, boolean, and string) arguments. Unfortunately, (I don't think?) property bags created from JS are thread-safe—the implementation of `ContractID` is [cycle-collected](https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/xpcom/ds/nsHashPropertyBag.h#46-55), and the `XPCVariant`s that back the properties definitely aren't thread-safe.

But the `HashPropertyBag` wrapper that we use in Rust _does_ use a thread-safe property bag, and its variants are also thread-safe. So let's provide a `TryFrom<&nsIPropertyBag>` implementation for `HashPropertyBag`, so we can clone a thread-safe bag from a potentially unsafe one.
In bug 1596322, we're adding a scriptable interface that takes an `in nsIPropertyBag` parameter, with primitive (number, boolean, and string) arguments. Unfortunately, (I don't think?) property bags created from JS are thread-safe—the implementation of `@mozilla.org/hash-property-bag;1` is [cycle-collected](https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/xpcom/ds/nsHashPropertyBag.h#46-55), and the [`XPCVariant`s](https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/js/xpconnect/src/xpcprivate.h#2102-2164) that back the properties definitely aren't thread-safe.

But the [`HashPropertyBag` wrapper](https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/storage/variant/src/bag.rs#15-16) that we use in Rust _does_ use a [thread-safe property bag](https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/xpcom/ds/nsHashPropertyBag.cpp#22-26), and its variants are [also thread-safe](https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/storage/Variant.h#49-57). So let's provide a `TryFrom<&nsIPropertyBag>` implementation for `HashPropertyBag`, so we can clone a thread-safe bag from a potentially unsafe one.

Back to Bug 1622949 Comment 0