import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1186307 - StructuredCloneHelper in workers.postMessage(), r=smaug (0d3c817afa)
- Bug 1183824 - Remove NS_ENSURE_TRUE(mCallback, NS_ERROR_NOT_INITIALIZED) warning from nsFrameMessageManager::DispatchAsyncMessageInternal. r=smaug (64dfd50f7f)
- Bug 1167189: Use a size annotation on the OOM abort. r=bholley (5e7fb331a0)
- missing crash reporter (47f183fab4)
- Bug 1137151: Marked destructor of |nsClipboard| as protected, r=mwu (5655bf8862)
- Bug 1194497 - Convert a few remaining PRUnichar to char16_t. r=roc (1554ffcec2)
- Bug 952456 - Part 1: Implement gonk/nsClipboard for rich text and raw image. r=fabrice (419381f7af)
- Bug 1198795 - ipc/StructuredCloneUtils should be merged with StructuredCloneHelper, r=smaug (02183262bd)
- Bug 1201806 - part 1 - Remove OwningSerializedStructuredCloneBuffer and use StructuredCloneIPCHelper everywhere in IPC code, r=smaug (6dc69151b4)
- Bug 1201806 - part 2 - nsStructuredCloneContainer should use StructuredCloneIPCHelper, r=smaug (b6ebaa8e95)
- Bug 1202028 - Implement range based for loops for SavedFrame stacks. r=terrence (57c198910c)
- missing bit of  Bug 1106264 (fa67f8ab56)
- Bug 1168806: Configurable I/O thread for socket IPC classes, r=kmachulis (213a8fb2b9)
- Bug 1159209: Remove template parameters from |DataSocketIO|, r=kmachulis (0d658c5cf8)
- Bug 1168806: Configurable consumer thread for socket IPC classes, r=kmachulis (ee054dd6b0)
- Bug 1167207: Add |BluetoothDaemonConnectionConsumer|, r=shuang (b8b89290df)
- Bug 1154281: Remove |UnixSocketConsumer| and its helpers, r=kmachulis (d40430b10f)
- Bug 1166638: Add |StreamSocketConsumer|, r=kmachulis (59b5c1abf3)
- Bug 1166638: Add |ListenSocketConsumer|, r=kmachulis (d119bcaa2a)
- Bug 1168806: Use 'consumer thread' in socket interface, r=kmachulis (65d232d21c)
- Bug 1170466: Inherit |ConnectionOrientedSocketIO| from |UnixSocketWatcher|, r=kmachulis (b91d0c624a)
- Bug 1170466: Share socket I/O methods in |ConnectionOrientedSocketIO|, r=kmachulis (108fb6696e)
- Bug 1170466: Implement accept and connect in |ConnectionOrientedSocketIO|, r=kmachulis (590b3b4617)
- Bug 1172479: Replace |nsIThread| by |MessageLoop| in socket I/O code, r=kmachulis (618073dcef)
- Bug 1203426 - Rename StructuredCloneIPCHelper to StructuredCloneData, r=smaug (dc31124113)
- Bug 1167392 - Change nsFrameMessageManager::mParentManager to a smart pointer. r=ehsan (98d60c0398)
- Bug 1186843 - Always cache delayed scripts in message manager (b0ab501959)
- Bug 1189550 - In parent process, cpmm.initialProcessData should be same as ppmm.initialProcessData (r=smaug) (7a8ab62432)
- Bug 1196057 - Use channel->Open2() in dom/base/nsFrameMessageManager.cpp (r=sicking) (a032d483d6)
- missing parts of Bug 1132072 - Tab switch refactoring (r=mconley) (e6fbbb722a)
- Bug 1175736 - Implement the iframe referrer attribute. r=ckerschb, r=bz (a5fc4e683b)
- Bug 1171017: Rename |BluetoothDaemonConnectionConsumer| to |DaemonSocketConsumer|, r=shuang (0af5957609)
- Bug 1170993: Manage socket buffers in sub-classes of |UnixSocketBuffer|, r=kmachulis (960de8be45)
- Bug 1171017: Rename |BluetoothDaemonPDUConsumer| to |DaemonSocketIOConsumer|, r=shuang (eea1681ab8)
- Bug 1171100 - Fix incorrect logic of handling Bluetooth Gatt Responses in daemon backend. r=tzimmermann (c385364d1e)
- Bug 1171866 - Remove ReversedUuidToString; f=tzimmermann, r=jocelyn (9b58176c39)
- Bug 1171017: Rename |BluetoothSocketPDU| to |DaemonSocketPDU|, r=shuang (ce1bbd9d4a)
- Bug 1171017: Rename |BluetoothDaemonConnectionIO| to |DaemonSocketIO|, r=shuang (00f2a38220)
- Bug 1171017: Rename |BluetoothDaemonConnection| to |DaemonSocket|, r=shuang (b3c3522719)
- Bug 1171017: Move classes from ipc/bluetooth to ipc/hal, r=shuang (047714aee4)
- Bug 1171994: Add |RilSocket| and |RilSocketConsumer|, r=htsai (276211bbb7)
- Bug 1171994: Forward received RIL socket I/O via |WorkerCrossThreadDispatcher|, r=htsai (7825d1c837)
- Bug 1185478: Add leak checks to socket I/O classes (40e2c01ce4)
- Bug 1185478: Remove strong references from socket I/O class to socket classes (6fa94f34ff)
- Bug 1163912: Set |Type| property of BluetoothDevice a initial value during LeScan; f=elin, r=jocelyn (bda66689ed)
- Bug 1166215 - Cast 'BluetoothTypeOfDevice' to uint32_t before the BT signal is distributed to BluetoothAdapter. r=joliu (d38ad4e55f)
- Bug 1170086 - Fix the parameter type of DispatchReplyError() in StartLeScan result handler. r=joliu (a24e23e02f)
- Bug 1161956 - Fix crashes while using GATT client functions. r=jocelyn (cebfb8c700)
- Bug 1171868 - Remove GeneratePathFromGattId(aId, aPath, aUuidStr); r=jocelyn (0eac291b3c)
- Bug 1161945 - Fix empty characteristics and descriptors after searching services. f=elin, r=jocelyn (a0d816fee4)
- Bug 1164387 - Use |btgatt_client_interface_t.get_device_type| to get the device type. r=jocelyn (c7b5c97a00)
- Bug 1173139 - Reorder global creation on workers, r=khuey. (acb79ae54e)
- Bug 1170071 - Part 1: Revise BluetoothGattInterface, result handler, and interface helper for daemon support of gatt server. r=shuang (0ad0c9244e)
- Bug 1170071 - Part 2: Add helpers for Bluetooth daemon GATT server support. r=shuang (46a4062579)
- Bug 1170071 - Part 3: Add gatt server support to GATT module for Bluetooth daemon. r=shuang (71d80aabea)
- Bug 1170071 - Part 4: Add Gatt server interfaces for Bluetooth daemon. r=shuang (a556aaf048)
- Bug 1187230: Convert Bluetooth to use daemon runnables, r=shuang (9be6501225)
- Bug 1204382: Add #include for nsIInputStream.h to MediaParent.cpp, to fix a build error in --disable-webrtc builds. r=jib (8b20e934)
This commit is contained in:
2022-03-18 12:44:46 +08:00
parent a06231e9d4
commit 36b2354fd4
148 changed files with 8207 additions and 5397 deletions
+109 -95
View File
@@ -37,9 +37,9 @@
#include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneUtils.h"
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/dom/ipc/BlobParent.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/dom/DOMStringList.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "nsPrintfCString.h"
@@ -47,6 +47,10 @@
#include "nsQueryObject.h"
#include <algorithm>
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
@@ -137,6 +141,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFrameMessageManager)
tmp->mListeners.EnumerateRead(CycleCollectorTraverseListeners,
static_cast<void*>(&cb));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChildManagers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@@ -151,6 +156,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFrameMessageManager)
Disconnect(false);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChildManagers)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentManager)
tmp->mInitialProcessData.setNull();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@@ -270,13 +276,14 @@ struct DataBlobs<Child>
template<ActorFlavorEnum Flavor>
static bool
BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType* aManager,
const StructuredCloneData& aData,
StructuredCloneData& aData,
ClonedMessageData& aClonedData)
{
SerializedStructuredCloneBuffer& buffer = aClonedData.data();
buffer.data = aData.mData;
buffer.dataLength = aData.mDataLength;
const nsTArray<nsRefPtr<BlobImpl>>& blobImpls = aData.mClosure.mBlobImpls;
buffer.data = aData.Data();
buffer.dataLength = aData.DataLength();
const nsTArray<nsRefPtr<BlobImpl>>& blobImpls = aData.BlobImpls();
if (!blobImpls.IsEmpty()) {
typedef typename BlobTraits<Flavor>::ProtocolType ProtocolType;
InfallibleTArray<ProtocolType*>& blobList = DataBlobs<Flavor>::Blobs(aClonedData);
@@ -296,7 +303,7 @@ BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType*
bool
MessageManagerCallback::BuildClonedMessageDataForParent(nsIContentParent* aParent,
const StructuredCloneData& aData,
StructuredCloneData& aData,
ClonedMessageData& aClonedData)
{
return BuildClonedMessageData<Parent>(aParent, aData, aClonedData);
@@ -304,25 +311,26 @@ MessageManagerCallback::BuildClonedMessageDataForParent(nsIContentParent* aParen
bool
MessageManagerCallback::BuildClonedMessageDataForChild(nsIContentChild* aChild,
const StructuredCloneData& aData,
StructuredCloneData& aData,
ClonedMessageData& aClonedData)
{
return BuildClonedMessageData<Child>(aChild, aData, aClonedData);
}
template<ActorFlavorEnum Flavor>
static StructuredCloneData
UnpackClonedMessageData(const ClonedMessageData& aData)
static void
UnpackClonedMessageData(const ClonedMessageData& aClonedData,
StructuredCloneData& aData)
{
const SerializedStructuredCloneBuffer& buffer = aData.data();
const SerializedStructuredCloneBuffer& buffer = aClonedData.data();
typedef typename BlobTraits<Flavor>::ProtocolType ProtocolType;
const InfallibleTArray<ProtocolType*>& blobs = DataBlobs<Flavor>::Blobs(aData);
StructuredCloneData cloneData;
cloneData.mData = buffer.data;
cloneData.mDataLength = buffer.dataLength;
const InfallibleTArray<ProtocolType*>& blobs = DataBlobs<Flavor>::Blobs(aClonedData);
aData.UseExternalData(buffer.data, buffer.dataLength);
if (!blobs.IsEmpty()) {
uint32_t length = blobs.Length();
cloneData.mClosure.mBlobImpls.SetCapacity(length);
aData.BlobImpls().SetCapacity(length);
for (uint32_t i = 0; i < length; ++i) {
auto* blob =
static_cast<typename BlobTraits<Flavor>::BlobType*>(blobs[i]);
@@ -331,22 +339,23 @@ UnpackClonedMessageData(const ClonedMessageData& aData)
nsRefPtr<BlobImpl> blobImpl = blob->GetBlobImpl();
MOZ_ASSERT(blobImpl);
cloneData.mClosure.mBlobImpls.AppendElement(blobImpl);
aData.BlobImpls().AppendElement(blobImpl);
}
}
return cloneData;
}
StructuredCloneData
mozilla::dom::ipc::UnpackClonedMessageDataForParent(const ClonedMessageData& aData)
void
mozilla::dom::ipc::UnpackClonedMessageDataForParent(const ClonedMessageData& aClonedData,
StructuredCloneData& aData)
{
return UnpackClonedMessageData<Parent>(aData);
UnpackClonedMessageData<Parent>(aClonedData, aData);
}
StructuredCloneData
mozilla::dom::ipc::UnpackClonedMessageDataForChild(const ClonedMessageData& aData)
void
mozilla::dom::ipc::UnpackClonedMessageDataForChild(const ClonedMessageData& aClonedData,
StructuredCloneData& aData)
{
return UnpackClonedMessageData<Child>(aData);
UnpackClonedMessageData<Child>(aClonedData, aData);
}
bool
@@ -509,16 +518,9 @@ nsFrameMessageManager::LoadScript(const nsAString& aURL,
bool aRunInGlobalScope)
{
if (aAllowDelayedLoad) {
if (IsGlobal() || IsBroadcaster()) {
// Cache for future windows or frames
mPendingScripts.AppendElement(aURL);
mPendingScriptsGlobalStates.AppendElement(aRunInGlobalScope);
} else if (!mCallback) {
// We're frame message manager, which isn't connected yet.
mPendingScripts.AppendElement(aURL);
mPendingScriptsGlobalStates.AppendElement(aRunInGlobalScope);
return NS_OK;
}
// Cache for future windows or frames
mPendingScripts.AppendElement(aURL);
mPendingScriptsGlobalStates.AppendElement(aRunInGlobalScope);
}
if (mCallback) {
@@ -643,15 +645,18 @@ JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData)
static bool
GetParamsForMessage(JSContext* aCx,
const JS::Value& aData,
JSAutoStructuredCloneBuffer& aBuffer,
StructuredCloneClosure& aClosure)
const JS::Value& aValue,
StructuredCloneData& aData)
{
// First try to use structured clone on the whole thing.
JS::RootedValue v(aCx, aData);
if (WriteStructuredClone(aCx, v, aBuffer, aClosure)) {
JS::RootedValue v(aCx, aValue);
ErrorResult rv;
aData.Write(aCx, v, rv);
if (!rv.Failed()) {
return true;
}
rv.SuppressException();
JS_ClearPendingException(aCx);
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
@@ -679,9 +684,14 @@ GetParamsForMessage(JSContext* aCx,
NS_ENSURE_TRUE(JS_ParseJSON(aCx, static_cast<const char16_t*>(json.get()),
json.Length(), &val), false);
return WriteStructuredClone(aCx, val, aBuffer, aClosure);
}
aData.Write(aCx, val, rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return false;
}
return true;
}
// nsISyncMessageSender
@@ -736,29 +746,25 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
}
StructuredCloneData data;
JSAutoStructuredCloneBuffer buffer;
if (aArgc >= 2 &&
!GetParamsForMessage(aCx, aJSON, buffer, data.mClosure)) {
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, data)) {
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
data.mData = buffer.data();
data.mDataLength = buffer.nbytes();
JS::Rooted<JSObject*> objects(aCx);
if (aArgc >= 3 && aObjects.isObject()) {
objects = &aObjects.toObject();
}
nsTArray<OwningSerializedStructuredCloneBuffer> retval;
nsTArray<StructuredCloneData> retval;
sSendingSyncMessage |= aIsSync;
bool rv = mCallback->DoSendBlockingMessage(aCx, aMessageName, data, objects,
bool ok = mCallback->DoSendBlockingMessage(aCx, aMessageName, data, objects,
aPrincipal, &retval, aIsSync);
if (aIsSync) {
sSendingSyncMessage = false;
}
if (!rv) {
if (!ok) {
return NS_OK;
}
@@ -768,8 +774,9 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
for (uint32_t i = 0; i < len; ++i) {
JS::Rooted<JS::Value> ret(aCx);
if (!JS_ReadStructuredClone(aCx, retval[i].data, retval[i].dataLength,
JS_STRUCTURED_CLONE_VERSION, &ret, nullptr, nullptr)) {
ErrorResult rv;
retval[i].Read(aCx, &ret, rv);
if (rv.Failed()) {
MOZ_ASSERT(false, "Unable to read structured clone in SendMessage");
return NS_ERROR_UNEXPECTED;
}
@@ -785,7 +792,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
nsresult
nsFrameMessageManager::DispatchAsyncMessageInternal(JSContext* aCx,
const nsAString& aMessage,
const StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
{
@@ -798,7 +805,10 @@ nsFrameMessageManager::DispatchAsyncMessageInternal(JSContext* aCx,
return NS_OK;
}
NS_ENSURE_TRUE(mCallback, NS_ERROR_NOT_INITIALIZED);
if (!mCallback) {
return NS_ERROR_NOT_INITIALIZED;
}
if (!mCallback->DoSendAsyncMessage(aCx, aMessage, aData, aCpows, aPrincipal)) {
return NS_ERROR_FAILURE;
}
@@ -814,10 +824,7 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
uint8_t aArgc)
{
StructuredCloneData data;
JSAutoStructuredCloneBuffer buffer;
if (aArgc >= 2 &&
!GetParamsForMessage(aCx, aJSON, buffer, data.mClosure)) {
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, data)) {
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
@@ -826,9 +833,6 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
objects = &aObjects.toObject();
}
data.mData = buffer.data();
data.mDataLength = buffer.nbytes();
return DispatchAsyncMessageInternal(aCx, aMessageName, data, objects,
aPrincipal);
}
@@ -1058,10 +1062,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
nsIFrameLoader* aTargetFrameLoader,
const nsAString& aMessage,
bool aIsSync,
const StructuredCloneData* aCloneData,
StructuredCloneData* aCloneData,
mozilla::jsipc::CpowHolder* aCpows,
nsIPrincipal* aPrincipal,
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
return ReceiveMessage(aTarget, aTargetFrameLoader, mClosed, aMessage, aIsSync,
aCloneData, aCpows, aPrincipal, aRetVal);
@@ -1073,10 +1077,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
bool aTargetClosed,
const nsAString& aMessage,
bool aIsSync,
const StructuredCloneData* aCloneData,
StructuredCloneData* aCloneData,
mozilla::jsipc::CpowHolder* aCpows,
nsIPrincipal* aPrincipal,
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners =
mListeners.Get(aMessage);
@@ -1157,10 +1161,14 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
JS::Rooted<JS::Value> cpowsv(cx, JS::ObjectValue(*cpows));
JS::Rooted<JS::Value> json(cx, JS::NullValue());
if (aCloneData && aCloneData->mDataLength &&
!ReadStructuredClone(cx, *aCloneData, &json)) {
JS_ClearPendingException(cx);
return NS_OK;
if (aCloneData && aCloneData->DataLength()) {
ErrorResult rv;
aCloneData->Read(cx, &json, rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
JS_ClearPendingException(cx);
return NS_OK;
}
}
JS::Rooted<JSString*> jsMessage(cx,
JS_NewUCStringCopyN(cx,
@@ -1251,8 +1259,11 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
continue;
}
if (aRetVal) {
JSAutoStructuredCloneBuffer buffer;
if (!buffer.write(cx, rval)) {
ErrorResult rv;
StructuredCloneData* data = aRetVal->AppendElement();
data->Write(cx, rval, rv);
if (NS_WARN_IF(rv.Failed())) {
aRetVal->RemoveElementAt(aRetVal->Length() - 1);
nsString msg = aMessage + NS_LITERAL_STRING(": message reply cannot be cloned. Are you trying to send an XPCOM object?");
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
@@ -1266,9 +1277,6 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
JS_ClearPendingException(cx);
continue;
}
OwningSerializedStructuredCloneBuffer* data = aRetVal->AppendElement();
buffer.steal(&data->data, &data->dataLength);
}
}
}
@@ -1423,6 +1431,14 @@ nsFrameMessageManager::GetInitialProcessData(JSContext* aCx, JS::MutableHandleVa
init.setObject(*obj);
}
if (!mChrome && XRE_IsParentProcess()) {
// This is the cpmm in the parent process. We should use the same object as the ppmm.
nsCOMPtr<nsIGlobalProcessScriptLoader> ppmm =
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
ppmm->GetInitialProcessData(aCx, &init);
mInitialProcessData = init;
}
if (!JS_WrapValue(aCx, &init)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -1736,7 +1752,7 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
NS_NewChannel(getter_AddRefs(channel),
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER);
if (!channel) {
@@ -1744,7 +1760,8 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
}
nsCOMPtr<nsIInputStream> input;
channel->Open(getter_AddRefs(input));
rv = channel->Open2(getter_AddRefs(input));
NS_ENSURE_SUCCESS_VOID(rv);
nsString dataString;
char16_t* dataStringBuf = nullptr;
size_t dataStringLength = 0;
@@ -1871,7 +1888,7 @@ class nsAsyncMessageToSameProcessChild : public nsSameProcessAsyncMessageBase,
public:
nsAsyncMessageToSameProcessChild(JSContext* aCx,
const nsAString& aMessage,
const StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal)
@@ -1913,7 +1930,7 @@ public:
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
const StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override
{
@@ -1967,10 +1984,10 @@ public:
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
const mozilla::dom::StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override
{
mozilla::dom::ContentChild* cc =
@@ -1996,7 +2013,7 @@ public:
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
const mozilla::dom::StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override
{
@@ -2026,7 +2043,7 @@ class nsAsyncMessageToSameProcessParent : public nsSameProcessAsyncMessageBase,
public:
nsAsyncMessageToSameProcessParent(JSContext* aCx,
const nsAString& aMessage,
const StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal)
@@ -2058,10 +2075,10 @@ public:
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
const mozilla::dom::StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
@@ -2078,7 +2095,7 @@ public:
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
const mozilla::dom::StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override
{
@@ -2155,7 +2172,6 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
NS_ENSURE_TRUE(global->Init(), NS_ERROR_UNEXPECTED);
global.forget(aResult);
return NS_OK;
}
static PLDHashOperator
@@ -2185,7 +2201,7 @@ nsFrameMessageManager::MarkForCC()
nsSameProcessAsyncMessageBase::nsSameProcessAsyncMessageBase(JSContext* aCx,
const nsAString& aMessage,
const StructuredCloneData& aData,
StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal)
: mRuntime(js::GetRuntime(aCx)),
@@ -2193,10 +2209,13 @@ nsSameProcessAsyncMessageBase::nsSameProcessAsyncMessageBase(JSContext* aCx,
mCpows(aCx, aCpows),
mPrincipal(aPrincipal)
{
if (aData.mDataLength && !mData.copy(aData.mData, aData.mDataLength)) {
NS_RUNTIMEABORT("OOM");
if (!mData.Copy(aData)) {
#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AsyncMessageOOM"),
NS_ConvertUTF16toUTF8(aMessage));
#endif
NS_ABORT_OOM(aData.DataLength());
}
mClosure = aData.mClosure;
}
void
@@ -2205,15 +2224,10 @@ nsSameProcessAsyncMessageBase::ReceiveMessage(nsISupports* aTarget,
nsFrameMessageManager* aManager)
{
if (aManager) {
StructuredCloneData data;
data.mData = mData.data();
data.mDataLength = mData.nbytes();
data.mClosure = mClosure;
SameProcessCpowHolder cpows(mRuntime, mCpows);
nsRefPtr<nsFrameMessageManager> mm = aManager;
mm->ReceiveMessage(aTarget, aTargetFrameLoader, mMessage, false, &data, &cpows,
mPrincipal, nullptr);
mm->ReceiveMessage(aTarget, aTargetFrameLoader, mMessage, false, &mData,
&cpows, mPrincipal, nullptr);
}
}