mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1201806 - part 1 - Remove OwningSerializedStructuredCloneBuffer and use StructuredCloneIPCHelper everywhere in IPC code, r=smaug
This commit is contained in:
parent
3c5cb07f03
commit
78330552e9
@ -11,6 +11,10 @@
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "nsIThread.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
namespace layers {
|
||||
|
@ -763,7 +763,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
|
||||
objects = &aObjects.toObject();
|
||||
}
|
||||
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer> retval;
|
||||
nsTArray<StructuredCloneIPCHelper> retval;
|
||||
|
||||
sSendingSyncMessage |= aIsSync;
|
||||
bool ok = mCallback->DoSendBlockingMessage(aCx, aMessageName, helper, objects,
|
||||
@ -782,8 +782,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;
|
||||
}
|
||||
@ -1072,7 +1073,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
StructuredCloneIPCHelper* aCloneHelper,
|
||||
mozilla::jsipc::CpowHolder* aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal)
|
||||
{
|
||||
return ReceiveMessage(aTarget, aTargetFrameLoader, mClosed, aMessage, aIsSync,
|
||||
aCloneHelper, aCpows, aPrincipal, aRetVal);
|
||||
@ -1087,7 +1088,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
StructuredCloneIPCHelper* aCloneHelper,
|
||||
mozilla::jsipc::CpowHolder* aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal)
|
||||
{
|
||||
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners =
|
||||
mListeners.Get(aMessage);
|
||||
@ -1266,8 +1267,11 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
continue;
|
||||
}
|
||||
if (aRetVal) {
|
||||
JSAutoStructuredCloneBuffer buffer;
|
||||
if (!buffer.write(cx, rval)) {
|
||||
ErrorResult rv;
|
||||
StructuredCloneIPCHelper* helper = aRetVal->AppendElement();
|
||||
helper->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));
|
||||
@ -1281,9 +1285,6 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
JS_ClearPendingException(cx);
|
||||
continue;
|
||||
}
|
||||
|
||||
OwningSerializedStructuredCloneBuffer* data = aRetVal->AppendElement();
|
||||
buffer.steal(&data->data, &data->dataLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1994,7 +1995,7 @@ public:
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync) override
|
||||
{
|
||||
mozilla::dom::ContentChild* cc =
|
||||
@ -2085,7 +2086,7 @@ public:
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync) override
|
||||
{
|
||||
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
|
||||
|
@ -34,9 +34,6 @@
|
||||
class nsIFrameLoader;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct OwningSerializedStructuredCloneBuffer;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class nsIContentParent;
|
||||
@ -57,9 +54,6 @@ enum MessageManagerFlags {
|
||||
|
||||
class MessageManagerCallback
|
||||
{
|
||||
protected:
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
|
||||
public:
|
||||
virtual ~MessageManagerCallback() {}
|
||||
|
||||
@ -73,7 +67,7 @@ public:
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject*> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync)
|
||||
{
|
||||
return true;
|
||||
@ -170,7 +164,6 @@ class nsFrameMessageManager final : public nsIContentFrameMessageManager,
|
||||
{
|
||||
friend class mozilla::dom::MessageManagerReporter;
|
||||
typedef mozilla::dom::StructuredCloneIPCHelper StructuredCloneIPCHelper;
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
public:
|
||||
nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
@ -201,7 +194,7 @@ public:
|
||||
const nsAString& aMessage,
|
||||
bool aIsSync, StructuredCloneIPCHelper* aCloneHelper,
|
||||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal);
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal);
|
||||
|
||||
void AddChildManager(nsFrameMessageManager* aManager);
|
||||
void RemoveChildManager(nsFrameMessageManager* aManager)
|
||||
@ -269,7 +262,7 @@ private:
|
||||
bool aTargetClosed, const nsAString& aMessage,
|
||||
bool aIsSync, StructuredCloneIPCHelper* aCloneHelper,
|
||||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal);
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal);
|
||||
|
||||
NS_IMETHOD LoadScript(const nsAString& aURL,
|
||||
bool aAllowDelayedLoad,
|
||||
|
@ -28,7 +28,7 @@ nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync)
|
||||
{
|
||||
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
|
||||
|
@ -35,7 +35,7 @@ class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
|
||||
public nsSupportsWeakReference,
|
||||
public mozilla::dom::ipc::MessageManagerCallback
|
||||
{
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
typedef mozilla::dom::StructuredCloneIPCHelper StructuredCloneIPCHelper;
|
||||
|
||||
public:
|
||||
nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
|
||||
@ -83,14 +83,14 @@ public:
|
||||
*/
|
||||
virtual bool DoSendBlockingMessage(JSContext* aCx,
|
||||
const nsAString& aMessage,
|
||||
mozilla::dom::StructuredCloneIPCHelper& aHelper,
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync) override;
|
||||
virtual bool DoSendAsyncMessage(JSContext* aCx,
|
||||
const nsAString& aMessage,
|
||||
mozilla::dom::StructuredCloneIPCHelper& aHelper,
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal) override;
|
||||
|
||||
|
@ -76,7 +76,7 @@ ContentBridgeParent::RecvSyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals)
|
||||
{
|
||||
return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
|
||||
aPrincipal, aRetvals);
|
||||
|
@ -19,7 +19,6 @@ class ContentBridgeParent : public PContentBridgeParent
|
||||
, public nsIContentParent
|
||||
, public nsIObserver
|
||||
{
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
public:
|
||||
explicit ContentBridgeParent(Transport* aTransport);
|
||||
|
||||
@ -83,7 +82,7 @@ protected:
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals) override;
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals) override;
|
||||
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
||||
|
@ -799,7 +799,7 @@ ContentChild::InitXPCOM()
|
||||
bool isConnected;
|
||||
ClipboardCapabilities clipboardCaps;
|
||||
DomainPolicyClone domainPolicy;
|
||||
OwningSerializedStructuredCloneBuffer initialData;
|
||||
StructuredCloneIPCHelper initialData;
|
||||
|
||||
SendGetXPCOMProcessAttributes(&isOffline, &isConnected,
|
||||
&isLangRTL, &mAvailableDictionaries,
|
||||
@ -831,9 +831,10 @@ ContentChild::InitXPCOM()
|
||||
if (NS_WARN_IF(!jsapi.Init(xpc::PrivilegedJunkScope()))) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
ErrorResult rv;
|
||||
JS::RootedValue data(jsapi.cx());
|
||||
if (!JS_ReadStructuredClone(jsapi.cx(), initialData.data, initialData.dataLength,
|
||||
JS_STRUCTURED_CLONE_VERSION, &data, nullptr, nullptr)) {
|
||||
initialData.Read(jsapi.cx(), &data, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
ProcessGlobal* global = ProcessGlobal::Get();
|
||||
|
@ -3022,7 +3022,7 @@ ContentParent::OnNewProcessCreated(uint32_t aPid,
|
||||
InfallibleTArray<nsString> unusedDictionaries;
|
||||
ClipboardCapabilities clipboardCaps;
|
||||
DomainPolicyClone domainPolicy;
|
||||
OwningSerializedStructuredCloneBuffer initialData;
|
||||
StructuredCloneIPCHelper initialData;
|
||||
|
||||
RecvGetXPCOMProcessAttributes(&isOffline, &isConnected,
|
||||
&isLangRTL, &unusedDictionaries,
|
||||
@ -3310,7 +3310,7 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
|
||||
InfallibleTArray<nsString>* dictionaries,
|
||||
ClipboardCapabilities* clipboardCaps,
|
||||
DomainPolicyClone* domainPolicy,
|
||||
OwningSerializedStructuredCloneBuffer* initialData)
|
||||
StructuredCloneIPCHelper* aInitialData)
|
||||
{
|
||||
nsCOMPtr<nsIIOService> io(do_GetIOService());
|
||||
MOZ_ASSERT(io, "No IO service?");
|
||||
@ -3357,12 +3357,11 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
|
||||
return false;
|
||||
}
|
||||
|
||||
JSAutoStructuredCloneBuffer buffer;
|
||||
if (!buffer.write(jsapi.cx(), init)) {
|
||||
ErrorResult rv;
|
||||
aInitialData->Write(jsapi.cx(), init, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer.steal(&initialData->data, &initialData->dataLength);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -4241,7 +4240,7 @@ ContentParent::RecvSyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals)
|
||||
{
|
||||
return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
|
||||
aPrincipal, aRetvals);
|
||||
@ -4252,7 +4251,7 @@ ContentParent::RecvRpcMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals)
|
||||
{
|
||||
return nsIContentParent::RecvRpcMessage(aMsg, aData, Move(aCpows), aPrincipal,
|
||||
aRetvals);
|
||||
|
@ -82,7 +82,6 @@ class ContentParent final : public PContentParent
|
||||
typedef mozilla::ipc::TestShellParent TestShellParent;
|
||||
typedef mozilla::ipc::URIParams URIParams;
|
||||
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
|
||||
public:
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
@ -202,7 +201,7 @@ public:
|
||||
bool aRunInGlobalScope) override;
|
||||
virtual bool DoSendAsyncMessage(JSContext* aCx,
|
||||
const nsAString& aMessage,
|
||||
mozilla::dom::StructuredCloneIPCHelper& aHelper,
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal) override;
|
||||
virtual bool CheckPermission(const nsAString& aPermission) override;
|
||||
@ -592,7 +591,7 @@ private:
|
||||
InfallibleTArray<nsString>* dictionaries,
|
||||
ClipboardCapabilities* clipboardCaps,
|
||||
DomainPolicyClone* domainPolicy,
|
||||
OwningSerializedStructuredCloneBuffer* initialData) override;
|
||||
StructuredCloneIPCHelper* initialData) override;
|
||||
|
||||
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
|
||||
|
||||
@ -753,12 +752,12 @@ private:
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals) override;
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals) override;
|
||||
virtual bool RecvRpcMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals) override;
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals) override;
|
||||
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
|
@ -64,7 +64,7 @@ using mozilla::WritingMode from "mozilla/WritingModes.h";
|
||||
using mozilla::layers::TouchBehaviorFlags from "mozilla/layers/APZUtils.h";
|
||||
using nsIWidget::TouchPointerState from "nsIWidget.h";
|
||||
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
|
||||
using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h";
|
||||
using class mozilla::dom::StructuredCloneIPCHelper from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::EventMessage from "mozilla/EventForwards.h";
|
||||
using nsEventStatus from "mozilla/EventForwards.h";
|
||||
using nsSizeMode from "nsIWidgetListener.h";
|
||||
@ -184,11 +184,11 @@ parent:
|
||||
|
||||
sync SyncMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (OwningSerializedStructuredCloneBuffer[] retval);
|
||||
returns (StructuredCloneIPCHelper[] retval);
|
||||
|
||||
prio(high) sync RpcMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (OwningSerializedStructuredCloneBuffer[] retval);
|
||||
returns (StructuredCloneIPCHelper[] retval);
|
||||
|
||||
/**
|
||||
* Notifies chrome that there is a focus change involving an editable
|
||||
|
@ -87,7 +87,7 @@ using gfxIntSize from "nsSize.h";
|
||||
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
|
||||
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
|
||||
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
|
||||
using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h";
|
||||
using class mozilla::dom::StructuredCloneIPCHelper from "ipc/IPCMessageUtils.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
{
|
||||
@ -685,7 +685,7 @@ parent:
|
||||
returns (bool isOffline, bool isConnected, bool isLangRTL, nsString[] dictionaries,
|
||||
ClipboardCapabilities clipboardCaps,
|
||||
DomainPolicyClone domainPolicy,
|
||||
OwningSerializedStructuredCloneBuffer initialData);
|
||||
StructuredCloneIPCHelper initialData);
|
||||
|
||||
sync CreateChildProcess(IPCTabContext context,
|
||||
ProcessPriority priority,
|
||||
@ -806,11 +806,11 @@ parent:
|
||||
|
||||
sync SyncMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (OwningSerializedStructuredCloneBuffer[] retval);
|
||||
returns (StructuredCloneIPCHelper[] retval);
|
||||
|
||||
prio(high) sync RpcMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (OwningSerializedStructuredCloneBuffer[] retval);
|
||||
returns (StructuredCloneIPCHelper[] retval);
|
||||
|
||||
ShowAlertNotification(nsString imageUrl,
|
||||
nsString title,
|
||||
|
@ -16,7 +16,7 @@ include PTabContext;
|
||||
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
|
||||
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
|
||||
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
|
||||
using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h";
|
||||
using class mozilla::dom::StructuredCloneIPCHelper from "ipc/IPCMessageUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -40,7 +40,7 @@ prio(normal upto urgent) sync protocol PContentBridge
|
||||
parent:
|
||||
sync SyncMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (OwningSerializedStructuredCloneBuffer[] retval);
|
||||
returns (StructuredCloneIPCHelper[] retval);
|
||||
both:
|
||||
// Both the parent and the child can construct the PBrowser.
|
||||
// See the comment in PContent::PBrowser().
|
||||
|
@ -79,5 +79,48 @@ StructuredCloneIPCHelper::Write(JSContext* aCx,
|
||||
mDataOwned = eJSAllocated;
|
||||
}
|
||||
|
||||
void
|
||||
StructuredCloneIPCHelper::WriteIPCParams(Message* aMsg) const
|
||||
{
|
||||
WriteParam(aMsg, mDataLength);
|
||||
|
||||
if (mDataLength) {
|
||||
// Structured clone data must be 64-bit aligned.
|
||||
aMsg->WriteBytes(mData, mDataLength, sizeof(uint64_t));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
StructuredCloneIPCHelper::ReadIPCParams(const IPC::Message* aMsg,
|
||||
void** aIter)
|
||||
{
|
||||
MOZ_ASSERT(!mData);
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &mDataLength)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mDataLength) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char** buffer =
|
||||
const_cast<const char**>(reinterpret_cast<char**>(&mData));
|
||||
// Structured clone data must be 64-bit aligned.
|
||||
if (!aMsg->ReadBytes(aIter, buffer, mDataLength, sizeof(uint64_t))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t* data = static_cast<uint64_t*>(js_malloc(mDataLength));
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(data, mData, mDataLength);
|
||||
mData = data;
|
||||
mDataOwned = eJSAllocated;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -9,6 +9,10 @@
|
||||
|
||||
#include "mozilla/dom/StructuredCloneHelper.h"
|
||||
|
||||
namespace IPC {
|
||||
class Message;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -24,6 +28,8 @@ public:
|
||||
, mDataOwned(eNone)
|
||||
{}
|
||||
|
||||
StructuredCloneIPCHelper(const StructuredCloneIPCHelper&) = delete;
|
||||
|
||||
~StructuredCloneIPCHelper()
|
||||
{
|
||||
if (mDataOwned == eAllocated) {
|
||||
@ -33,6 +39,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
StructuredCloneIPCHelper&
|
||||
operator=(const StructuredCloneIPCHelper& aOther) = delete;
|
||||
|
||||
const nsTArray<nsRefPtr<BlobImpl>>& BlobImpls() const
|
||||
{
|
||||
return mBlobImplArray;
|
||||
@ -71,6 +80,10 @@ public:
|
||||
return mDataLength;
|
||||
}
|
||||
|
||||
// For IPC serialization
|
||||
void WriteIPCParams(IPC::Message* aMessage) const;
|
||||
bool ReadIPCParams(const IPC::Message* aMessage, void** aIter);
|
||||
|
||||
private:
|
||||
uint64_t* mData;
|
||||
size_t mDataLength;
|
||||
|
@ -2892,7 +2892,7 @@ TabChild::DoSendBlockingMessage(JSContext* aCx,
|
||||
StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync)
|
||||
{
|
||||
ClonedMessageData data;
|
||||
|
@ -228,7 +228,6 @@ class TabChild final : public TabChildBase,
|
||||
public nsITooltipListener
|
||||
{
|
||||
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
typedef mozilla::layout::RenderFrameChild RenderFrameChild;
|
||||
typedef mozilla::layers::APZEventState APZEventState;
|
||||
typedef mozilla::layers::SetTargetAPZCCallback SetTargetAPZCCallback;
|
||||
@ -280,7 +279,7 @@ public:
|
||||
mozilla::dom::StructuredCloneIPCHelper& aHelper,
|
||||
JS::Handle<JSObject *> aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal,
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal,
|
||||
bool aIsSync) override;
|
||||
virtual bool DoSendAsyncMessage(JSContext* aCx,
|
||||
const nsAString& aMessage,
|
||||
@ -532,11 +531,6 @@ protected:
|
||||
private:
|
||||
/**
|
||||
* Create a new TabChild object.
|
||||
*
|
||||
* |aOwnOrContainingAppId| is the app-id of our frame or of the closest app
|
||||
* frame in the hierarchy which contains us.
|
||||
*
|
||||
* |aIsBrowserElement| indicates whether we're a browser (but not an app).
|
||||
*/
|
||||
TabChild(nsIContentChild* aManager,
|
||||
const TabId& aTabId,
|
||||
|
@ -1866,7 +1866,7 @@ TabParent::RecvSyncMessage(const nsString& aMessage,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal)
|
||||
{
|
||||
// FIXME Permission check for TabParent in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
@ -1890,7 +1890,7 @@ TabParent::RecvRpcMessage(const nsString& aMessage,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal)
|
||||
{
|
||||
// FIXME Permission check for TabParent in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
@ -2666,7 +2666,7 @@ TabParent::ReceiveMessage(const nsString& aMessage,
|
||||
StructuredCloneIPCHelper* aHelper,
|
||||
CpowHolder* aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal)
|
||||
{
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader(true);
|
||||
if (frameLoader && frameLoader->GetFrameMessageManager()) {
|
||||
|
@ -80,7 +80,6 @@ class TabParent final : public PBrowserParent
|
||||
, public nsIWebBrowserPersistable
|
||||
{
|
||||
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
|
||||
virtual ~TabParent();
|
||||
|
||||
@ -156,12 +155,12 @@ public:
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal) override;
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal) override;
|
||||
virtual bool RecvRpcMessage(const nsString& aMessage,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal) override;
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetVal) override;
|
||||
virtual bool RecvAsyncMessage(const nsString& aMessage,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
@ -448,7 +447,7 @@ protected:
|
||||
StructuredCloneIPCHelper* aHelper,
|
||||
mozilla::jsipc::CpowHolder* aCpows,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aJSONRetVal = nullptr);
|
||||
nsTArray<StructuredCloneIPCHelper>* aJSONRetVal = nullptr);
|
||||
|
||||
virtual bool RecvAsyncAuthPrompt(const nsCString& aUri,
|
||||
const nsString& aRealm,
|
||||
|
@ -187,7 +187,7 @@ nsIContentParent::RecvSyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals)
|
||||
{
|
||||
// FIXME Permission check in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
@ -216,7 +216,7 @@ nsIContentParent::RecvRpcMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals)
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals)
|
||||
{
|
||||
// FIXME Permission check in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
|
@ -47,8 +47,6 @@ class nsIContentParent : public nsISupports
|
||||
, public mozilla::dom::ipc::MessageManagerCallback
|
||||
, public CPOWManagerGetter
|
||||
{
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer OwningSerializedStructuredCloneBuffer;
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTPARENT_IID)
|
||||
|
||||
@ -104,12 +102,12 @@ protected: // IPDL methods
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals);
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals);
|
||||
virtual bool RecvRpcMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals);
|
||||
nsTArray<StructuredCloneIPCHelper>* aRetvals);
|
||||
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/StructuredCloneIPCHelper.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#ifdef XP_WIN
|
||||
@ -64,11 +65,6 @@ struct SerializedStructuredCloneBuffer
|
||||
: data(nullptr), dataLength(0)
|
||||
{ }
|
||||
|
||||
explicit SerializedStructuredCloneBuffer(const JSAutoStructuredCloneBuffer& aOther)
|
||||
{
|
||||
*this = aOther;
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const SerializedStructuredCloneBuffer& aOther) const
|
||||
{
|
||||
@ -76,47 +72,10 @@ struct SerializedStructuredCloneBuffer
|
||||
this->dataLength == aOther.dataLength;
|
||||
}
|
||||
|
||||
SerializedStructuredCloneBuffer&
|
||||
operator=(const JSAutoStructuredCloneBuffer& aOther)
|
||||
{
|
||||
data = aOther.data();
|
||||
dataLength = aOther.nbytes();
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint64_t* data;
|
||||
size_t dataLength;
|
||||
};
|
||||
|
||||
struct OwningSerializedStructuredCloneBuffer : public SerializedStructuredCloneBuffer
|
||||
{
|
||||
OwningSerializedStructuredCloneBuffer()
|
||||
{}
|
||||
|
||||
OwningSerializedStructuredCloneBuffer(const OwningSerializedStructuredCloneBuffer&) = delete;
|
||||
|
||||
explicit OwningSerializedStructuredCloneBuffer(const JSAutoStructuredCloneBuffer& aOther)
|
||||
: SerializedStructuredCloneBuffer(aOther)
|
||||
{}
|
||||
|
||||
~OwningSerializedStructuredCloneBuffer()
|
||||
{
|
||||
if (data) {
|
||||
js_free(data);
|
||||
}
|
||||
}
|
||||
|
||||
OwningSerializedStructuredCloneBuffer&
|
||||
operator=(const JSAutoStructuredCloneBuffer& aOther)
|
||||
{
|
||||
SerializedStructuredCloneBuffer::operator=(aOther);
|
||||
return *this;
|
||||
}
|
||||
|
||||
OwningSerializedStructuredCloneBuffer&
|
||||
operator=(const OwningSerializedStructuredCloneBuffer& aOther) = delete;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
namespace IPC {
|
||||
@ -738,6 +697,27 @@ struct ParamTraits<mozilla::TimeStampValue>
|
||||
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::StructuredCloneIPCHelper>
|
||||
{
|
||||
typedef mozilla::dom::StructuredCloneIPCHelper paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
aParam.WriteIPCParams(aMsg);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
return aResult->ReadIPCParams(aMsg, aIter);
|
||||
}
|
||||
|
||||
static void Log(const paramType& aParam, std::wstring* aLog)
|
||||
{
|
||||
LogParam(aParam.DataLength(), aLog);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::SerializedStructuredCloneBuffer>
|
||||
{
|
||||
@ -779,31 +759,6 @@ struct ParamTraits<mozilla::SerializedStructuredCloneBuffer>
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::OwningSerializedStructuredCloneBuffer>
|
||||
: public ParamTraits<mozilla::SerializedStructuredCloneBuffer>
|
||||
{
|
||||
typedef mozilla::OwningSerializedStructuredCloneBuffer paramType;
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
if (!ParamTraits<mozilla::SerializedStructuredCloneBuffer>::Read(aMsg, aIter, aResult)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aResult->data) {
|
||||
uint64_t* data = static_cast<uint64_t*>(js_malloc(aResult->dataLength));
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
memcpy(data, aResult->data, aResult->dataLength);
|
||||
aResult->data = data;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<nsIWidget::TouchPointerState>
|
||||
: public BitFlagsEnumSerializer<nsIWidget::TouchPointerState,
|
||||
|
Loading…
Reference in New Issue
Block a user