MakeAndAddRef ensures that the freshly-allocated object immediately gets a
refcount of 1 (before it's even passed to AddScriptRunner). This avoids
several potential footguns that otherwise exist with a zero-refcount
freshly-allocated object.
It also makes the ownership-transfer semantics more clear
(via the already_AddRefed type that it produces) - AddScriptRunner is taking
ownership of the object, rather than using it temporarily while the caller
maintains ownership.
Differential Revision: https://phabricator.services.mozilla.com/D299039
This patch is to remove the ClonedMessageData type which is currently
frequently used for sending a StructuredCloneData over IPC manually. Instead,
under the new approach, the StructuredCloneData is transferred directly using
its serializer.
This allows for simplification of various types across the codebase which
previously needed complex handling for this manual {de-}serialization step,
especially around keeping the borrowed-from buffers alive in some cases.
As part of this, the type has also been changed to be a threadsafe refcounted
object. This is in part possible due to earlier parts, which have made it safe
to Read() from the same StructuredCloneData object concurrently from multiple
threads (so long as it does not support transferrables).
The underlying data storage within StructuredCloneData was previously already
reference counted (due to SharedJSAllocatedData).
In addition to StructuredCloneData, other data structures (e.g.
nsStructuredCloneContainer and SharedMessageBody) have also been updated to be
serialized directly, avoiding now-unnecessary intermediate objects.
Differential Revision: https://phabricator.services.mozilla.com/D281115
Previously, we would copy the data and deserialize it once for each listener.
This interacts poorly with the actual data which can be sent over the message
manager, as it is possible to include transferables (which must only be
deserialized once).
This new approach ensures that the data structure is always deserialized once
in the shared scope, and then passed to all of the listeners, avoiding issues
with deserializing the same transferable multiple times.
Differential Revision: https://phabricator.services.mozilla.com/D281553
This reverts commit 72c32e25bf.
Revert "Bug 2013389 - Part 11: Make attachment arrays more consistent in StructuredCloneHolder, r=asuth"
This reverts commit c0912428c7.
Revert "Bug 2013389 - Part 10: Fix version tracking in nsStructuredCloneContainer, r=asuth,extension-reviewers,spidermonkey-reviewers,sfink,robwu"
This reverts commit f2e9691831.
Revert "Bug 2013389 - Part 9: Remove the now-unused ReadFromBuffer method, r=asuth"
This reverts commit 6eb034458e.
Revert "Bug 2013389 - Part 8: Avoid the unnecessary ClonedMessageData intermediate, r=asuth,mccr8,extension-reviewers,dom-worker-reviewers,robwu"
This reverts commit 4dd6f1d6ea.
Revert "Bug 2013389 - Part 7: Only deserialize once in nsFrameMessageManager, r=asuth"
This reverts commit 65d16af619.
Revert "Bug 2013389 - Part 6: Remove weak listener support from MessageManager, r=smaug"
This reverts commit 66f4b308a0.
Revert "Bug 2013389 - Part 5: Broadcasting MessageManagers cannot support transferrables, r=asuth"
This reverts commit e95e1a5a6c.
Revert "Bug 2013389 - Part 4: Avoid depending on mErrorMessage when deserializing StructuredCloneHolder, r=asuth,dom-worker-reviewers"
This reverts commit ae78c69357.
Revert "Bug 2013389 - Part 3: Remove aGlobal argument from StructuredCloneHolder::Read, r=asuth,dom-worker-reviewers"
This reverts commit 066bd37bfd.
Revert "Bug 2013389 - Part 2: Stop tracking mGlobal within StructuredCloneHolder::Read, r=asuth"
This reverts commit 6b4f3a43c0.
Revert "Bug 2013389 - Part 1: Add an Adopt API to StructuredCloneHolder, r=asuth"
This reverts commit 8624db71c2.
This patch is to remove the ClonedMessageData type which is currently
frequently used for sending a StructuredCloneData over IPC manually. Instead,
under the new approach, the StructuredCloneData is transferred directly using
its serializer.
This allows for simplification of various types across the codebase which
previously needed complex handling for this manual {de-}serialization step,
especially around keeping the borrowed-from buffers alive in some cases.
As part of this, the type has also been changed to be a threadsafe refcounted
object. This is in part possible due to earlier parts, which have made it safe
to Read() from the same StructuredCloneData object concurrently from multiple
threads (so long as it does not support transferrables).
The underlying data storage within StructuredCloneData was previously already
reference counted (due to SharedJSAllocatedData).
In addition to StructuredCloneData, other data structures (e.g.
nsStructuredCloneContainer and SharedMessageBody) have also been updated to be
serialized directly, avoiding now-unnecessary intermediate objects.
Differential Revision: https://phabricator.services.mozilla.com/D281115
Previously, we would copy the data and deserialize it once for each listener.
This interacts poorly with the actual data which can be sent over the message
manager, as it is possible to include transferables (which must only be
deserialized once).
This new approach ensures that the data structure is always deserialized once
in the shared scope, and then passed to all of the listeners, avoiding issues
with deserializing the same transferable multiple times.
Differential Revision: https://phabricator.services.mozilla.com/D281553
This reverts commit 5c5cf7465b.
Revert "Bug 2013389 - Part 10: Fix version tracking in nsStructuredCloneContainer, r=asuth,extension-reviewers,spidermonkey-reviewers,sfink,robwu"
This reverts commit c87a327d86.
Revert "Bug 2013389 - Part 9: Remove the now-unused ReadFromBuffer method, r=asuth"
This reverts commit 5adf49e5d8.
Revert "Bug 2013389 - Part 8: Avoid the unnecessary ClonedMessageData intermediate, r=asuth,mccr8,extension-reviewers,dom-worker-reviewers,robwu"
This reverts commit f6d12563fe.
Revert "Bug 2013389 - Part 7: Only deserialize once in nsFrameMessageManager, r=asuth"
This reverts commit 44c1325d76.
Revert "Bug 2013389 - Part 6: Remove weak listener support from MessageManager, r=smaug"
This reverts commit 1d1b495c91.
Revert "Bug 2013389 - Part 5: Broadcasting MessageManagers cannot support transferrables, r=asuth"
This reverts commit e2eb75ff8f.
Revert "Bug 2013389 - Part 4: Avoid depending on mErrorMessage when deserializing StructuredCloneHolder, r=asuth,dom-worker-reviewers"
This reverts commit d9a234ad7b.
Revert "Bug 2013389 - Part 3: Remove aGlobal argument from StructuredCloneHolder::Read, r=asuth,dom-worker-reviewers"
This reverts commit 48279cea50.
Revert "Bug 2013389 - Part 2: Stop tracking mGlobal within StructuredCloneHolder::Read, r=asuth"
This reverts commit 27162e5046.
Revert "Bug 2013389 - Part 1: Add an Adopt API to StructuredCloneHolder, r=asuth"
This reverts commit e3a9f32716.
This patch is to remove the ClonedMessageData type which is currently
frequently used for sending a StructuredCloneData over IPC manually. Instead,
under the new approach, the StructuredCloneData is transferred directly using
its serializer.
This allows for simplification of various types across the codebase which
previously needed complex handling for this manual {de-}serialization step,
especially around keeping the borrowed-from buffers alive in some cases.
As part of this, the type has also been changed to be a threadsafe refcounted
object. This is in part possible due to earlier parts, which have made it safe
to Read() from the same StructuredCloneData object concurrently from multiple
threads (so long as it does not support transferrables).
The underlying data storage within StructuredCloneData was previously already
reference counted (due to SharedJSAllocatedData).
In addition to StructuredCloneData, other data structures (e.g.
nsStructuredCloneContainer and SharedMessageBody) have also been updated to be
serialized directly, avoiding now-unnecessary intermediate objects.
Differential Revision: https://phabricator.services.mozilla.com/D281115
Previously, we would copy the data and deserialize it once for each listener.
This interacts poorly with the actual data which can be sent over the message
manager, as it is possible to include transferables (which must only be
deserialized once).
This new approach ensures that the data structure is always deserialized once
in the shared scope, and then passed to all of the listeners, avoiding issues
with deserializing the same transferable multiple times.
Differential Revision: https://phabricator.services.mozilla.com/D281553
While SCD doesn't have the problems that its parent classes have in terms
of moving, people have done a poor job of keeping the move constructor
updated as they add new auxiliary arrays. This led to strange behavior where
something would work when being sent between processes, but would crash
with a bounds error when being sent within a process.
This patch addresses the problem by preventing SCD from being moved. Instead,
UniquePtr<StructuredCloneData> must be used to move them around.
The dropping of the "using" of SCD from PBrowser means a few related places
have to explicitly qualify SCD with the ipc namespace.
Differential Revision: https://phabricator.services.mozilla.com/D262718
This reverts commit cd2962e220.
Revert "Bug 1977139, part 1 - Use macro for HasClonedDOMObjects and StructuredCloneHolder::Read. r=asuth"
This reverts commit 2cc5ec76dd.
While SCD doesn't have the problems that its parent classes have in terms
of moving, people have done a poor job of keeping the move constructor
updated as they add new auxiliary arrays. This led to strange behavior where
something would work when being sent between processes, but would crash
with a bounds error when being sent within a process.
This patch addresses the problem by preventing SCD from being moved. Instead,
UniquePtr<StructuredCloneData> must be used to move them around.
The dropping of the "using" of SCD from PBrowser means a few related places
have to explicitly qualify SCD with the ipc namespace.
Differential Revision: https://phabricator.services.mozilla.com/D262718
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.
Differential Revision: https://phabricator.services.mozilla.com/D256800
This method always returned GetMainThreadSerialEventTarget(). This patch
switches all callers over to use that method instead.
We can't easily switch all calls to be calls to NS_GetMainThread(), as there is
no version of that method returning a bare nsIThread* instance.
I didn't introduce one, as we may want to add a lock around mMainThread in the
future, which would require removing nsThreadManager::GetMainThreadWeak. As
this method only returns nsISerialEventTarget, it method could remain
implemented, however, by returning a statically allocated fake event target
which forwards dispatches (and QIs to nsIThread) to the real main thread.
Differential Revision: https://phabricator.services.mozilla.com/D166608
This method always returned GetMainThreadSerialEventTarget(). This patch
switches all callers over to use that method instead.
We can't easily switch all calls to be calls to NS_GetMainThread(), as there is
no version of that method returning a bare nsIThread* instance.
I didn't introduce one, as we may want to add a lock around mMainThread in the
future, which would require removing nsThreadManager::GetMainThreadWeak. As
this method only returns nsISerialEventTarget, it method could remain
implemented, however, by returning a statically allocated fake event target
which forwards dispatches (and QIs to nsIThread) to the real main thread.
Differential Revision: https://phabricator.services.mozilla.com/D166608
There's a pattern of clearing JS things when calling mozilla::DropJSObjects,
but mozilla::DropJSObjects already clears the JS things itself by calling
CycleCollectedJSRuntime::RemoveJSHolder.
Differential Revision: https://phabricator.services.mozilla.com/D115885
This commit:
- removes sendRpcMessage, which was unused;
- removes the CPOW argument to sendAsyncMessage, broadcastAsyncMessage, and
sendSyncMessage;
- removes the aIsSync argument used internally to distinguish sendRpcMessage
and sendSyncMessage;
- removes CPOW tests;
- updates the few remaining callsites that use more than 2 arguments in
sendAsyncMessage for the removal of the cpows argument.
Differential Revision: https://phabricator.services.mozilla.com/D71514
These were added for the sake of app browsers, and all of the code which
actually needed them has since been removed.
Differential Revision: https://phabricator.services.mozilla.com/D70741
These were added for the sake of app browsers, and all of the code which
actually needed them has since been removed.
Differential Revision: https://phabricator.services.mozilla.com/D70741
These were added for the sake of app browsers, and all of the code which
actually needed them has since been removed.
Differential Revision: https://phabricator.services.mozilla.com/D70741
This covers most cycle collected objects which support weak references, but
not the ones which inherit from a cycle collected class and don't do any cycle
collection on their own.
Differential Revision: https://phabricator.services.mozilla.com/D63962
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55442
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55442