Bug 1203426 - Rename StructuredCloneIPCHelper to StructuredCloneData, r=smaug

This commit is contained in:
Andrea Marchesini 2015-09-10 21:50:58 +01:00
parent 2db78de40a
commit edb0027da6
32 changed files with 242 additions and 232 deletions

View File

@ -92,7 +92,7 @@
#include "nsSandboxFlags.h"
#include "mozilla/layers/CompositorChild.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/WebBrowserPersistLocalDocument.h"
#ifdef MOZ_XUL
@ -2447,10 +2447,10 @@ public:
nsAsyncMessageToChild(JSContext* aCx,
nsFrameLoader* aFrameLoader,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aHelper, aCpows, aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal)
, mFrameLoader(aFrameLoader)
{
}
@ -2472,7 +2472,7 @@ public:
bool
nsFrameLoader::DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
{
@ -2480,7 +2480,7 @@ nsFrameLoader::DoSendAsyncMessage(JSContext* aCx,
if (tabParent) {
ClonedMessageData data;
nsIContentParent* cp = tabParent->Manager();
if (!BuildClonedMessageDataForParent(cp, aHelper, data)) {
if (!BuildClonedMessageDataForParent(cp, aData, data)) {
return false;
}
InfallibleTArray<mozilla::jsipc::CpowEntry> cpows;
@ -2494,7 +2494,7 @@ nsFrameLoader::DoSendAsyncMessage(JSContext* aCx,
if (mChildMessageManager) {
nsCOMPtr<nsIRunnable> ev = new nsAsyncMessageToChild(aCx, this, aMessage,
aHelper, aCpows,
aData, aCpows,
aPrincipal);
NS_DispatchToCurrentThread(ev);
return true;

View File

@ -41,10 +41,13 @@ namespace mozilla {
namespace dom {
class ContentParent;
class PBrowserParent;
class StructuredCloneIPCHelper;
class TabParent;
} // namespace dom
namespace ipc {
class StructuredCloneData;
} // namespace ipc
namespace layout {
class RenderFrameParent;
} // namespace layout
@ -90,7 +93,7 @@ public:
bool aRunInGlobalScope) override;
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
mozilla::dom::StructuredCloneIPCHelper& aHelper,
mozilla::dom::ipc::StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override;
virtual bool CheckPermission(const nsAString& aPermission) override;

View File

@ -37,9 +37,9 @@
#include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneIPCHelper.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"
@ -276,13 +276,13 @@ struct DataBlobs<Child>
template<ActorFlavorEnum Flavor>
static bool
BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType* aManager,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
ClonedMessageData& aClonedData)
{
SerializedStructuredCloneBuffer& buffer = aClonedData.data();
buffer.data = aHelper.Data();
buffer.dataLength = aHelper.DataLength();
const nsTArray<nsRefPtr<BlobImpl>>& blobImpls = aHelper.BlobImpls();
buffer.data = aData.Data();
buffer.dataLength = aData.DataLength();
const nsTArray<nsRefPtr<BlobImpl>>& blobImpls = aData.BlobImpls();
if (!blobImpls.IsEmpty()) {
typedef typename BlobTraits<Flavor>::ProtocolType ProtocolType;
@ -303,34 +303,34 @@ BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType*
bool
MessageManagerCallback::BuildClonedMessageDataForParent(nsIContentParent* aParent,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
ClonedMessageData& aClonedData)
{
return BuildClonedMessageData<Parent>(aParent, aHelper, aClonedData);
return BuildClonedMessageData<Parent>(aParent, aData, aClonedData);
}
bool
MessageManagerCallback::BuildClonedMessageDataForChild(nsIContentChild* aChild,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
ClonedMessageData& aClonedData)
{
return BuildClonedMessageData<Child>(aChild, aHelper, aClonedData);
return BuildClonedMessageData<Child>(aChild, aData, aClonedData);
}
template<ActorFlavorEnum Flavor>
static void
UnpackClonedMessageData(const ClonedMessageData& aData,
StructuredCloneIPCHelper& aHelper)
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);
const InfallibleTArray<ProtocolType*>& blobs = DataBlobs<Flavor>::Blobs(aClonedData);
aHelper.UseExternalData(buffer.data, buffer.dataLength);
aData.UseExternalData(buffer.data, buffer.dataLength);
if (!blobs.IsEmpty()) {
uint32_t length = blobs.Length();
aHelper.BlobImpls().SetCapacity(length);
aData.BlobImpls().SetCapacity(length);
for (uint32_t i = 0; i < length; ++i) {
auto* blob =
static_cast<typename BlobTraits<Flavor>::BlobType*>(blobs[i]);
@ -339,23 +339,23 @@ UnpackClonedMessageData(const ClonedMessageData& aData,
nsRefPtr<BlobImpl> blobImpl = blob->GetBlobImpl();
MOZ_ASSERT(blobImpl);
aHelper.BlobImpls().AppendElement(blobImpl);
aData.BlobImpls().AppendElement(blobImpl);
}
}
}
void
mozilla::dom::ipc::UnpackClonedMessageDataForParent(const ClonedMessageData& aData,
StructuredCloneIPCHelper& aHelper)
mozilla::dom::ipc::UnpackClonedMessageDataForParent(const ClonedMessageData& aClonedData,
StructuredCloneData& aData)
{
UnpackClonedMessageData<Parent>(aData, aHelper);
UnpackClonedMessageData<Parent>(aClonedData, aData);
}
void
mozilla::dom::ipc::UnpackClonedMessageDataForChild(const ClonedMessageData& aData,
StructuredCloneIPCHelper& aHelper)
mozilla::dom::ipc::UnpackClonedMessageDataForChild(const ClonedMessageData& aClonedData,
StructuredCloneData& aData)
{
UnpackClonedMessageData<Child>(aData, aHelper);
UnpackClonedMessageData<Child>(aClonedData, aData);
}
bool
@ -652,13 +652,13 @@ JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData)
static bool
GetParamsForMessage(JSContext* aCx,
const JS::Value& aData,
StructuredCloneIPCHelper& aHelper)
const JS::Value& aValue,
StructuredCloneData& aData)
{
// First try to use structured clone on the whole thing.
JS::RootedValue v(aCx, aData);
JS::RootedValue v(aCx, aValue);
ErrorResult rv;
aHelper.Write(aCx, v, rv);
aData.Write(aCx, v, rv);
if (!rv.Failed()) {
return true;
}
@ -691,7 +691,7 @@ GetParamsForMessage(JSContext* aCx,
NS_ENSURE_TRUE(JS_ParseJSON(aCx, static_cast<const char16_t*>(json.get()),
json.Length(), &val), false);
aHelper.Write(aCx, val, rv);
aData.Write(aCx, val, rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return false;
@ -700,7 +700,6 @@ GetParamsForMessage(JSContext* aCx,
return true;
}
// nsISyncMessageSender
static bool sSendingSyncMessage = false;
@ -753,8 +752,8 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
return NS_ERROR_UNEXPECTED;
}
StructuredCloneIPCHelper helper;
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, helper)) {
StructuredCloneData data;
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, data)) {
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
@ -763,10 +762,10 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
objects = &aObjects.toObject();
}
nsTArray<StructuredCloneIPCHelper> retval;
nsTArray<StructuredCloneData> retval;
sSendingSyncMessage |= aIsSync;
bool ok = mCallback->DoSendBlockingMessage(aCx, aMessageName, helper, objects,
bool ok = mCallback->DoSendBlockingMessage(aCx, aMessageName, data, objects,
aPrincipal, &retval, aIsSync);
if (aIsSync) {
sSendingSyncMessage = false;
@ -800,7 +799,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
nsresult
nsFrameMessageManager::DispatchAsyncMessageInternal(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
{
@ -808,7 +807,7 @@ nsFrameMessageManager::DispatchAsyncMessageInternal(JSContext* aCx,
int32_t len = mChildManagers.Count();
for (int32_t i = 0; i < len; ++i) {
static_cast<nsFrameMessageManager*>(mChildManagers[i])->
DispatchAsyncMessageInternal(aCx, aMessage, aHelper, aCpows, aPrincipal);
DispatchAsyncMessageInternal(aCx, aMessage, aData, aCpows, aPrincipal);
}
return NS_OK;
}
@ -817,7 +816,7 @@ nsFrameMessageManager::DispatchAsyncMessageInternal(JSContext* aCx,
return NS_ERROR_NOT_INITIALIZED;
}
if (!mCallback->DoSendAsyncMessage(aCx, aMessage, aHelper, aCpows, aPrincipal)) {
if (!mCallback->DoSendAsyncMessage(aCx, aMessage, aData, aCpows, aPrincipal)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -831,8 +830,8 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
JSContext* aCx,
uint8_t aArgc)
{
StructuredCloneIPCHelper helper;
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, helper)) {
StructuredCloneData data;
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, data)) {
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
@ -841,7 +840,7 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
objects = &aObjects.toObject();
}
return DispatchAsyncMessageInternal(aCx, aMessageName, helper, objects,
return DispatchAsyncMessageInternal(aCx, aMessageName, data, objects,
aPrincipal);
}
@ -1070,13 +1069,13 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
nsIFrameLoader* aTargetFrameLoader,
const nsAString& aMessage,
bool aIsSync,
StructuredCloneIPCHelper* aCloneHelper,
StructuredCloneData* aCloneData,
mozilla::jsipc::CpowHolder* aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
return ReceiveMessage(aTarget, aTargetFrameLoader, mClosed, aMessage, aIsSync,
aCloneHelper, aCpows, aPrincipal, aRetVal);
aCloneData, aCpows, aPrincipal, aRetVal);
}
nsresult
@ -1085,10 +1084,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
bool aTargetClosed,
const nsAString& aMessage,
bool aIsSync,
StructuredCloneIPCHelper* aCloneHelper,
StructuredCloneData* aCloneData,
mozilla::jsipc::CpowHolder* aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners =
mListeners.Get(aMessage);
@ -1169,9 +1168,9 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
JS::Rooted<JS::Value> cpowsv(cx, JS::ObjectValue(*cpows));
JS::Rooted<JS::Value> json(cx, JS::NullValue());
if (aCloneHelper && aCloneHelper->DataLength()) {
if (aCloneData && aCloneData->DataLength()) {
ErrorResult rv;
aCloneHelper->Read(cx, &json, rv);
aCloneData->Read(cx, &json, rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
JS_ClearPendingException(cx);
@ -1268,8 +1267,8 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
}
if (aRetVal) {
ErrorResult rv;
StructuredCloneIPCHelper* helper = aRetVal->AppendElement();
helper->Write(cx, rval, 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?");
@ -1292,7 +1291,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
nsRefPtr<nsFrameMessageManager> kungfuDeathGrip = mParentManager;
return mParentManager ? mParentManager->ReceiveMessage(aTarget, aTargetFrameLoader,
aTargetClosed, aMessage,
aIsSync, aCloneHelper,
aIsSync, aCloneData,
aCpows, aPrincipal,
aRetVal) : NS_OK;
}
@ -1896,10 +1895,10 @@ class nsAsyncMessageToSameProcessChild : public nsSameProcessAsyncMessageBase,
public:
nsAsyncMessageToSameProcessChild(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aHelper, aCpows, aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal)
{
}
@ -1938,12 +1937,12 @@ public:
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override
{
nsCOMPtr<nsIRunnable> ev =
new nsAsyncMessageToSameProcessChild(aCx, aMessage, aHelper, aCpows,
new nsAsyncMessageToSameProcessChild(aCx, aMessage, aData, aCpows,
aPrincipal);
NS_DispatchToCurrentThread(ev);
return true;
@ -1992,10 +1991,10 @@ public:
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override
{
mozilla::dom::ContentChild* cc =
@ -2004,7 +2003,7 @@ public:
return true;
}
ClonedMessageData data;
if (!BuildClonedMessageDataForChild(cc, aHelper, data)) {
if (!BuildClonedMessageDataForChild(cc, aData, data)) {
return false;
}
InfallibleTArray<mozilla::jsipc::CpowEntry> cpows;
@ -2021,7 +2020,7 @@ public:
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override
{
@ -2031,7 +2030,7 @@ public:
return true;
}
ClonedMessageData data;
if (!BuildClonedMessageDataForChild(cc, aHelper, data)) {
if (!BuildClonedMessageDataForChild(cc, aData, data)) {
return false;
}
InfallibleTArray<mozilla::jsipc::CpowEntry> cpows;
@ -2051,10 +2050,10 @@ class nsAsyncMessageToSameProcessParent : public nsSameProcessAsyncMessageBase,
public:
nsAsyncMessageToSameProcessParent(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aHelper, aCpows, aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal)
{
}
@ -2083,10 +2082,10 @@ public:
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
@ -2096,20 +2095,20 @@ public:
SameProcessCpowHolder cpows(js::GetRuntime(aCx), aCpows);
nsRefPtr<nsFrameMessageManager> ppm = nsFrameMessageManager::sSameProcessParentManager;
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()), nullptr, aMessage,
true, &aHelper, &cpows, aPrincipal, aRetVal);
true, &aData, &cpows, aPrincipal, aRetVal);
}
return true;
}
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
nsRefPtr<nsAsyncMessageToSameProcessParent> ev =
new nsAsyncMessageToSameProcessParent(aCx, aMessage, aHelper, aCpows, aPrincipal);
new nsAsyncMessageToSameProcessParent(aCx, aMessage, aData, aCpows, aPrincipal);
queue->Push(ev);
return true;
}
@ -2209,7 +2208,7 @@ nsFrameMessageManager::MarkForCC()
nsSameProcessAsyncMessageBase::nsSameProcessAsyncMessageBase(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal)
: mRuntime(js::GetRuntime(aCx)),
@ -2217,12 +2216,12 @@ nsSameProcessAsyncMessageBase::nsSameProcessAsyncMessageBase(JSContext* aCx,
mCpows(aCx, aCpows),
mPrincipal(aPrincipal)
{
if (!mHelper.Copy(aHelper)) {
if (!mData.Copy(aData)) {
#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AsyncMessageOOM"),
NS_ConvertUTF16toUTF8(aMessage));
#endif
NS_ABORT_OOM(aHelper.DataLength());
NS_ABORT_OOM(aData.DataLength());
}
}
@ -2235,7 +2234,7 @@ nsSameProcessAsyncMessageBase::ReceiveMessage(nsISupports* aTarget,
SameProcessCpowHolder cpows(mRuntime, mCpows);
nsRefPtr<nsFrameMessageManager> mm = aManager;
mm->ReceiveMessage(aTarget, aTargetFrameLoader, mMessage, false, &mHelper,
mm->ReceiveMessage(aTarget, aTargetFrameLoader, mMessage, false, &mData,
&cpows, mPrincipal, nullptr);
}
}

View File

@ -28,7 +28,7 @@
#include "js/RootingAPI.h"
#include "nsTObserverArray.h"
#include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/jsipc/CpowHolder.h"
class nsIFrameLoader;
@ -64,10 +64,10 @@ public:
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync)
{
return true;
@ -75,7 +75,7 @@ public:
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal)
{
@ -110,18 +110,18 @@ public:
protected:
bool BuildClonedMessageDataForParent(nsIContentParent* aParent,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
ClonedMessageData& aClonedData);
bool BuildClonedMessageDataForChild(nsIContentChild* aChild,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
ClonedMessageData& aClonedData);
};
void UnpackClonedMessageDataForParent(const ClonedMessageData& aData,
StructuredCloneIPCHelper& aHelper);
void UnpackClonedMessageDataForParent(const ClonedMessageData& aClonedData,
StructuredCloneData& aData);
void UnpackClonedMessageDataForChild(const ClonedMessageData& aData,
StructuredCloneIPCHelper& aHelper);
void UnpackClonedMessageDataForChild(const ClonedMessageData& aClonedData,
StructuredCloneData& aData);
} // namespace ipc
} // namespace dom
@ -163,7 +163,7 @@ class nsFrameMessageManager final : public nsIContentFrameMessageManager,
public nsIProcessChecker
{
friend class mozilla::dom::MessageManagerReporter;
typedef mozilla::dom::StructuredCloneIPCHelper StructuredCloneIPCHelper;
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
public:
nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback,
nsFrameMessageManager* aParentManager,
@ -192,9 +192,9 @@ public:
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
const nsAString& aMessage,
bool aIsSync, StructuredCloneIPCHelper* aCloneHelper,
bool aIsSync, StructuredCloneData* aCloneData,
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal);
nsTArray<StructuredCloneData>* aRetVal);
void AddChildManager(nsFrameMessageManager* aManager);
void RemoveChildManager(nsFrameMessageManager* aManager)
@ -219,7 +219,7 @@ public:
uint8_t aArgc);
nsresult DispatchAsyncMessageInternal(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal);
void RemoveFromParent();
@ -260,9 +260,9 @@ private:
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
bool aTargetClosed, const nsAString& aMessage,
bool aIsSync, StructuredCloneIPCHelper* aCloneHelper,
bool aIsSync, StructuredCloneData* aCloneData,
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal);
nsTArray<StructuredCloneData>* aRetVal);
NS_IMETHOD LoadScript(const nsAString& aURL,
bool aAllowDelayedLoad,
@ -326,11 +326,11 @@ private:
class nsSameProcessAsyncMessageBase
{
public:
typedef mozilla::dom::StructuredCloneIPCHelper StructuredCloneIPCHelper;
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
nsSameProcessAsyncMessageBase(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal);
@ -342,7 +342,7 @@ private:
JSRuntime* mRuntime;
nsString mMessage;
StructuredCloneIPCHelper mHelper;
StructuredCloneData mData;
JS::PersistentRooted<JSObject*> mCpows;
nsCOMPtr<nsIPrincipal> mPrincipal;
};

View File

@ -21,14 +21,15 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
bool
nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync)
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
@ -38,7 +39,7 @@ nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
SameProcessCpowHolder cpows(js::GetRuntime(aCx), aCpows);
nsRefPtr<nsFrameMessageManager> mm = mChromeMessageManager;
nsCOMPtr<nsIFrameLoader> fl = GetFrameLoader();
mm->ReceiveMessage(mOwner, fl, aMessage, true, &aHelper, &cpows, aPrincipal,
mm->ReceiveMessage(mOwner, fl, aMessage, true, &aData, &cpows, aPrincipal,
aRetVal);
}
return true;
@ -51,10 +52,10 @@ public:
nsAsyncMessageToParent(JSContext* aCx,
nsInProcessTabChildGlobal* aTabChild,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
: nsSameProcessAsyncMessageBase(aCx, aMessage, aHelper, aCpows, aPrincipal),
: nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal),
mTabChild(aTabChild)
{
}
@ -71,13 +72,13 @@ public:
bool
nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
nsRefPtr<nsAsyncMessageToParent> ev =
new nsAsyncMessageToParent(aCx, this, aMessage, aHelper, aCpows, aPrincipal);
new nsAsyncMessageToParent(aCx, this, aMessage, aData, aCpows, aPrincipal);
queue->Push(ev);
return true;
}

View File

@ -35,7 +35,7 @@ class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
public nsSupportsWeakReference,
public mozilla::dom::ipc::MessageManagerCallback
{
typedef mozilla::dom::StructuredCloneIPCHelper StructuredCloneIPCHelper;
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
public:
nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
@ -83,14 +83,14 @@ public:
*/
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override;
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override;

View File

@ -9,7 +9,7 @@
#include "nsIStructuredCloneContainer.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#define NS_STRUCTUREDCLONECONTAINER_CONTRACTID \
"@mozilla.org/docshell/structured-clone-container;1"
@ -23,7 +23,7 @@
class nsStructuredCloneContainer final
: public nsIStructuredCloneContainer
, public mozilla::dom::StructuredCloneIPCHelper
, public mozilla::dom::ipc::StructuredCloneData
{
public:
nsStructuredCloneContainer();

View File

@ -40,7 +40,7 @@ EnsureBluetoothSocketHalLoad()
}
class mozilla::dom::bluetooth::DroidSocketImpl
: public ipc::UnixFdWatcher
: public mozilla::ipc::UnixFdWatcher
, public DataSocketIO
{
public:
@ -74,7 +74,7 @@ public:
DroidSocketImpl(MessageLoop* aConsumerLoop,
MessageLoop* aIOLoop,
BluetoothSocket* aConsumer)
: ipc::UnixFdWatcher(aIOLoop)
: mozilla::ipc::UnixFdWatcher(aIOLoop)
, DataSocketIO(aConsumerLoop)
, mConsumer(aConsumer)
, mShuttingDownOnIOThread(false)

View File

@ -11,11 +11,11 @@
#include "mozilla/dom/File.h"
#include "mozilla/dom/MessageEvent.h"
#include "mozilla/dom/MessageEventBinding.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "WorkerPrivate.h"
namespace mozilla {
@ -85,17 +85,17 @@ BroadcastChannelChild::RecvNotify(const ClonedMessageData& aData)
return true;
}
StructuredCloneIPCHelper cloneHelper;
cloneHelper.BlobImpls().AppendElements(blobs);
ipc::StructuredCloneData cloneData;
cloneData.BlobImpls().AppendElements(blobs);
const SerializedStructuredCloneBuffer& buffer = aData.data();
cloneHelper.UseExternalData(buffer.data, buffer.dataLength);
cloneData.UseExternalData(buffer.data, buffer.dataLength);
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> value(cx, JS::NullValue());
if (buffer.dataLength) {
ErrorResult rv;
cloneHelper.Read(cx, &value, rv);
cloneData.Read(cx, &value, rv);
if (NS_WARN_IF(rv.Failed())) {
return true;
}

View File

@ -84,7 +84,7 @@ ChannelInfo::InitFromChromeGlobal(nsIGlobalObject* aGlobal)
}
void
ChannelInfo::InitFromIPCChannelInfo(const ipc::IPCChannelInfo& aChannelInfo)
ChannelInfo::InitFromIPCChannelInfo(const mozilla::ipc::IPCChannelInfo& aChannelInfo)
{
MOZ_ASSERT(!mInited, "Cannot initialize the object twice");
@ -172,7 +172,7 @@ ChannelInfo::ResurrectInfoOnChannel(nsIChannel* aChannel)
return NS_OK;
}
ipc::IPCChannelInfo
mozilla::ipc::IPCChannelInfo
ChannelInfo::AsIPCChannelInfo() const
{
// This may be called when mInited is false, for example if we try to store

View File

@ -76,7 +76,7 @@ ContentBridgeParent::RecvSyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals)
nsTArray<StructuredCloneData>* aRetvals)
{
return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
aPrincipal, aRetvals);

View File

@ -82,7 +82,7 @@ protected:
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals) override;
nsTArray<StructuredCloneData>* aRetvals) override;
virtual bool RecvAsyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,

View File

@ -178,13 +178,13 @@
#endif
#include "ProcessUtils.h"
#include "StructuredCloneIPCHelper.h"
#include "URIUtils.h"
#include "nsContentUtils.h"
#include "nsIPrincipal.h"
#include "nsDeviceStorage.h"
#include "DomainPolicy.h"
#include "mozilla/dom/DataStoreService.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/dom/telephony/PTelephonyChild.h"
#include "mozilla/dom/time/DateCacheCleaner.h"
#include "mozilla/dom/voicemail/VoicemailIPCService.h"
@ -799,7 +799,7 @@ ContentChild::InitXPCOM()
bool isConnected;
ClipboardCapabilities clipboardCaps;
DomainPolicyClone domainPolicy;
StructuredCloneIPCHelper initialData;
StructuredCloneData initialData;
SendGetXPCOMProcessAttributes(&isOffline, &isConnected,
&isLangRTL, &mAvailableDictionaries,
@ -2083,11 +2083,11 @@ ContentChild::RecvAsyncMessage(const nsString& aMsg,
{
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::GetChildProcessManager();
if (cpm) {
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForChild(aData, helper);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForChild(aData, data);
CrossProcessCpowHolder cpows(this, aCpows);
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()), nullptr,
aMsg, false, &helper, &cpows, aPrincipal, nullptr);
aMsg, false, &data, &cpows, aPrincipal, nullptr);
}
return true;
}

View File

@ -155,7 +155,6 @@
#include "SandboxHal.h"
#include "ScreenManagerParent.h"
#include "SourceSurfaceRawData.h"
#include "StructuredCloneIPCHelper.h"
#include "TabParent.h"
#include "URIUtils.h"
#include "nsIWebBrowserChrome.h"
@ -166,6 +165,7 @@
#include "prio.h"
#include "private/pprio.h"
#include "ContentProcessManager.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/psm/PSMContentListener.h"
#include "nsPluginHost.h"
#include "nsPluginTags.h"
@ -3024,7 +3024,7 @@ ContentParent::OnNewProcessCreated(uint32_t aPid,
InfallibleTArray<nsString> unusedDictionaries;
ClipboardCapabilities clipboardCaps;
DomainPolicyClone domainPolicy;
StructuredCloneIPCHelper initialData;
StructuredCloneData initialData;
RecvGetXPCOMProcessAttributes(&isOffline, &isConnected,
&isLangRTL, &unusedDictionaries,
@ -3312,7 +3312,7 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
InfallibleTArray<nsString>* dictionaries,
ClipboardCapabilities* clipboardCaps,
DomainPolicyClone* domainPolicy,
StructuredCloneIPCHelper* aInitialData)
StructuredCloneData* aInitialData)
{
nsCOMPtr<nsIIOService> io(do_GetIOService());
MOZ_ASSERT(io, "No IO service?");
@ -4253,7 +4253,7 @@ ContentParent::RecvSyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals)
nsTArray<StructuredCloneData>* aRetvals)
{
return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
aPrincipal, aRetvals);
@ -4264,7 +4264,7 @@ ContentParent::RecvRpcMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals)
nsTArray<StructuredCloneData>* aRetvals)
{
return nsIContentParent::RecvRpcMessage(aMsg, aData, Move(aCpows), aPrincipal,
aRetvals);
@ -4502,7 +4502,7 @@ ContentParent::DoLoadMessageManagerScript(const nsAString& aURL,
bool
ContentParent::DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aHelper,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
{

View File

@ -201,7 +201,7 @@ public:
bool aRunInGlobalScope) override;
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override;
virtual bool CheckPermission(const nsAString& aPermission) override;
@ -591,7 +591,7 @@ private:
InfallibleTArray<nsString>* dictionaries,
ClipboardCapabilities* clipboardCaps,
DomainPolicyClone* domainPolicy,
StructuredCloneIPCHelper* initialData) override;
StructuredCloneData* initialData) override;
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
@ -754,12 +754,12 @@ private:
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals) override;
nsTArray<StructuredCloneData>* aRetvals) override;
virtual bool RecvRpcMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals) override;
nsTArray<StructuredCloneData>* aRetvals) override;
virtual bool RecvAsyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,

View File

@ -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 class mozilla::dom::StructuredCloneIPCHelper from "ipc/IPCMessageUtils.h";
using class mozilla::dom::ipc::StructuredCloneData 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 (StructuredCloneIPCHelper[] retval);
returns (StructuredCloneData[] retval);
prio(high) sync RpcMessage(nsString aMessage, ClonedMessageData aData,
CpowEntry[] aCpows, Principal aPrincipal)
returns (StructuredCloneIPCHelper[] retval);
returns (StructuredCloneData[] retval);
/**
* Notifies chrome that there is a focus change involving an editable

View File

@ -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 class mozilla::dom::StructuredCloneIPCHelper from "ipc/IPCMessageUtils.h";
using class mozilla::dom::ipc::StructuredCloneData from "ipc/IPCMessageUtils.h";
union ChromeRegistryItem
{
@ -685,7 +685,7 @@ parent:
returns (bool isOffline, bool isConnected, bool isLangRTL, nsString[] dictionaries,
ClipboardCapabilities clipboardCaps,
DomainPolicyClone domainPolicy,
StructuredCloneIPCHelper initialData);
StructuredCloneData initialData);
sync CreateChildProcess(IPCTabContext context,
ProcessPriority priority,
@ -808,11 +808,11 @@ parent:
sync SyncMessage(nsString aMessage, ClonedMessageData aData,
CpowEntry[] aCpows, Principal aPrincipal)
returns (StructuredCloneIPCHelper[] retval);
returns (StructuredCloneData[] retval);
prio(high) sync RpcMessage(nsString aMessage, ClonedMessageData aData,
CpowEntry[] aCpows, Principal aPrincipal)
returns (StructuredCloneIPCHelper[] retval);
returns (StructuredCloneData[] retval);
ShowAlertNotification(nsString imageUrl,
nsString title,

View File

@ -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 class mozilla::dom::StructuredCloneIPCHelper from "ipc/IPCMessageUtils.h";
using class mozilla::dom::ipc::StructuredCloneData 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 (StructuredCloneIPCHelper[] retval);
returns (StructuredCloneData[] retval);
both:
// Both the parent and the child can construct the PBrowser.
// See the comment in PContent::PBrowser().

View File

@ -4,7 +4,7 @@
* 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/. */
#include "StructuredCloneIPCHelper.h"
#include "StructuredCloneData.h"
#include "nsIDOMDOMException.h"
#include "nsIMutable.h"
@ -22,27 +22,28 @@
namespace mozilla {
namespace dom {
namespace ipc {
bool
StructuredCloneIPCHelper::Copy(const StructuredCloneIPCHelper& aHelper)
StructuredCloneData::Copy(const StructuredCloneData& aData)
{
if (!aHelper.mData) {
if (!aData.mData) {
return true;
}
uint64_t* data = static_cast<uint64_t*>(js_malloc(aHelper.mDataLength));
uint64_t* data = static_cast<uint64_t*>(js_malloc(aData.mDataLength));
if (!data) {
return false;
}
memcpy(data, aHelper.mData, aHelper.mDataLength);
memcpy(data, aData.mData, aData.mDataLength);
mData = data;
mDataLength = aHelper.mDataLength;
mDataLength = aData.mDataLength;
mDataOwned = eJSAllocated;
MOZ_ASSERT(BlobImpls().IsEmpty());
BlobImpls().AppendElements(aHelper.BlobImpls());
BlobImpls().AppendElements(aData.BlobImpls());
MOZ_ASSERT(GetImages().IsEmpty());
@ -50,9 +51,9 @@ StructuredCloneIPCHelper::Copy(const StructuredCloneIPCHelper& aHelper)
}
void
StructuredCloneIPCHelper::Read(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue,
ErrorResult &aRv)
StructuredCloneData::Read(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue,
ErrorResult &aRv)
{
MOZ_ASSERT(mData);
@ -63,9 +64,9 @@ StructuredCloneIPCHelper::Read(JSContext* aCx,
}
void
StructuredCloneIPCHelper::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ErrorResult &aRv)
StructuredCloneData::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ErrorResult &aRv)
{
MOZ_ASSERT(!mData);
@ -80,7 +81,7 @@ StructuredCloneIPCHelper::Write(JSContext* aCx,
}
void
StructuredCloneIPCHelper::WriteIPCParams(Message* aMsg) const
StructuredCloneData::WriteIPCParams(Message* aMsg) const
{
WriteParam(aMsg, mDataLength);
@ -91,8 +92,8 @@ StructuredCloneIPCHelper::WriteIPCParams(Message* aMsg) const
}
bool
StructuredCloneIPCHelper::ReadIPCParams(const IPC::Message* aMsg,
void** aIter)
StructuredCloneData::ReadIPCParams(const IPC::Message* aMsg,
void** aIter)
{
MOZ_ASSERT(!mData);
@ -123,8 +124,8 @@ StructuredCloneIPCHelper::ReadIPCParams(const IPC::Message* aMsg,
}
bool
StructuredCloneIPCHelper::CopyExternalData(const void* aData,
size_t aDataLength)
StructuredCloneData::CopyExternalData(const void* aData,
size_t aDataLength)
{
MOZ_ASSERT(!mData);
uint64_t* data = static_cast<uint64_t*>(js_malloc(aDataLength));
@ -140,5 +141,6 @@ StructuredCloneIPCHelper::CopyExternalData(const void* aData,
return true;
}
} // namespace ipc
} // namespace dom
} // namespace mozilla

View File

@ -4,8 +4,8 @@
* 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/. */
#ifndef mozilla_dom_StructuredCloneIPCHelper_h
#define mozilla_dom_StructuredCloneIPCHelper_h
#ifndef mozilla_dom_ipc_StructuredCloneData_h
#define mozilla_dom_ipc_StructuredCloneData_h
#include "mozilla/dom/StructuredCloneHelper.h"
@ -15,11 +15,12 @@ class Message;
namespace mozilla {
namespace dom {
namespace ipc {
class StructuredCloneIPCHelper : public StructuredCloneHelper
class StructuredCloneData : public StructuredCloneHelper
{
public:
StructuredCloneIPCHelper()
StructuredCloneData()
: StructuredCloneHelper(StructuredCloneHelper::CloningSupported,
StructuredCloneHelper::TransferringNotSupported,
StructuredCloneHelper::DifferentProcess)
@ -28,17 +29,17 @@ public:
, mDataOwned(eNone)
{}
StructuredCloneIPCHelper(const StructuredCloneIPCHelper&) = delete;
StructuredCloneData(const StructuredCloneData&) = delete;
~StructuredCloneIPCHelper()
~StructuredCloneData()
{
if (mDataOwned == eJSAllocated) {
js_free(mData);
}
}
StructuredCloneIPCHelper&
operator=(const StructuredCloneIPCHelper& aOther) = delete;
StructuredCloneData&
operator=(const StructuredCloneData& aOther) = delete;
const nsTArray<nsRefPtr<BlobImpl>>& BlobImpls() const
{
@ -50,7 +51,7 @@ public:
return mBlobImplArray;
}
bool Copy(const StructuredCloneIPCHelper& aHelper);
bool Copy(const StructuredCloneData& aData);
void Read(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue,
@ -93,7 +94,8 @@ private:
} mDataOwned;
};
} // namespace ipc
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_StructuredCloneIPCHelper_h
#endif // mozilla_dom_ipc_StructuredCloneData_h

View File

@ -83,7 +83,7 @@
#include "nsWindowWatcher.h"
#include "PermissionMessageUtils.h"
#include "PuppetWidget.h"
#include "StructuredCloneIPCHelper.h"
#include "StructuredCloneData.h"
#include "nsViewportInfo.h"
#include "nsILoadContext.h"
#include "ipc/nsGUIEventIPC.h"
@ -237,13 +237,13 @@ TabChildBase::DispatchMessageManagerMessage(const nsAString& aMessageName,
{
AutoSafeJSContext cx;
JS::Rooted<JS::Value> json(cx, JS::NullValue());
StructuredCloneIPCHelper helper;
StructuredCloneData data;
if (JS_ParseJSON(cx,
static_cast<const char16_t*>(aJSONData.BeginReading()),
aJSONData.Length(),
&json)) {
ErrorResult rv;
helper.Write(cx, json, rv);
data.Write(cx, json, rv);
if (NS_WARN_IF(rv.Failed())) {
return;
}
@ -255,7 +255,7 @@ TabChildBase::DispatchMessageManagerMessage(const nsAString& aMessageName,
nsRefPtr<nsFrameMessageManager> mm =
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
aMessageName, false, &helper, nullptr, nullptr, nullptr);
aMessageName, false, &data, nullptr, nullptr, nullptr);
}
bool
@ -2459,13 +2459,13 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
{
if (mTabChildGlobal) {
nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(GetGlobal());
StructuredCloneIPCHelper helper;
UnpackClonedMessageDataForChild(aData, helper);
StructuredCloneData data;
UnpackClonedMessageDataForChild(aData, data);
nsRefPtr<nsFrameMessageManager> mm =
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
CrossProcessCpowHolder cpows(Manager(), aCpows);
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
aMessage, false, &helper, &cpows, aPrincipal, nullptr);
aMessage, false, &data, &cpows, aPrincipal, nullptr);
}
return true;
}
@ -2895,14 +2895,14 @@ TabChild::SetTabId(const TabId& aTabId)
bool
TabChild::DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync)
{
ClonedMessageData data;
if (!BuildClonedMessageDataForChild(Manager(), aHelper, data)) {
if (!BuildClonedMessageDataForChild(Manager(), aData, data)) {
return false;
}
InfallibleTArray<CpowEntry> cpows;
@ -2921,12 +2921,12 @@ TabChild::DoSendBlockingMessage(JSContext* aCx,
bool
TabChild::DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal)
{
ClonedMessageData data;
if (!BuildClonedMessageDataForChild(Manager(), aHelper, data)) {
if (!BuildClonedMessageDataForChild(Manager(), aData, data)) {
return false;
}
InfallibleTArray<CpowEntry> cpows;

View File

@ -276,14 +276,14 @@ public:
*/
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
mozilla::dom::StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal,
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override;
virtual bool DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
mozilla::dom::StructuredCloneIPCHelper& aHelper,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override;
virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,

View File

@ -79,7 +79,7 @@
#include "nsWindowWatcher.h"
#include "private/pprio.h"
#include "PermissionMessageUtils.h"
#include "StructuredCloneIPCHelper.h"
#include "StructuredCloneData.h"
#include "ColorPickerParent.h"
#include "FilePickerParent.h"
#include "TabChild.h"
@ -1866,7 +1866,7 @@ TabParent::RecvSyncMessage(const nsString& aMessage,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
// FIXME Permission check for TabParent in Content process
nsIPrincipal* principal = aPrincipal;
@ -1878,11 +1878,11 @@ TabParent::RecvSyncMessage(const nsString& aMessage,
}
}
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForParent(aData, helper);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
CrossProcessCpowHolder cpows(Manager(), aCpows);
return ReceiveMessage(aMessage, true, &helper, &cpows, aPrincipal, aRetVal);
return ReceiveMessage(aMessage, true, &data, &cpows, aPrincipal, aRetVal);
}
bool
@ -1890,7 +1890,7 @@ TabParent::RecvRpcMessage(const nsString& aMessage,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
// FIXME Permission check for TabParent in Content process
nsIPrincipal* principal = aPrincipal;
@ -1902,11 +1902,11 @@ TabParent::RecvRpcMessage(const nsString& aMessage,
}
}
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForParent(aData, helper);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
CrossProcessCpowHolder cpows(Manager(), aCpows);
return ReceiveMessage(aMessage, true, &helper, &cpows, aPrincipal, aRetVal);
return ReceiveMessage(aMessage, true, &data, &cpows, aPrincipal, aRetVal);
}
bool
@ -1925,11 +1925,11 @@ TabParent::RecvAsyncMessage(const nsString& aMessage,
}
}
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForParent(aData, helper);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
CrossProcessCpowHolder cpows(Manager(), aCpows);
return ReceiveMessage(aMessage, false, &helper, &cpows, aPrincipal, nullptr);
return ReceiveMessage(aMessage, false, &data, &cpows, aPrincipal, nullptr);
}
bool
@ -2663,10 +2663,10 @@ TabParent::RecvDispatchFocusToTopLevelWindow()
bool
TabParent::ReceiveMessage(const nsString& aMessage,
bool aSync,
StructuredCloneIPCHelper* aHelper,
StructuredCloneData* aData,
CpowHolder* aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal)
nsTArray<StructuredCloneData>* aRetVal)
{
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader(true);
if (frameLoader && frameLoader->GetFrameMessageManager()) {
@ -2677,7 +2677,7 @@ TabParent::ReceiveMessage(const nsString& aMessage,
frameLoader,
aMessage,
aSync,
aHelper,
aData,
aCpows,
aPrincipal,
aRetVal);

View File

@ -67,7 +67,10 @@ class ClonedMessageData;
class nsIContentParent;
class Element;
class DataTransfer;
class StructuredCloneIPCHelper;
namespace ipc {
class StructuredCloneData;
} // ipc namespace
class TabParent final : public PBrowserParent
, public nsIDOMEventListener
@ -155,12 +158,12 @@ public:
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal) override;
nsTArray<ipc::StructuredCloneData>* aRetVal) override;
virtual bool RecvRpcMessage(const nsString& aMessage,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetVal) override;
nsTArray<ipc::StructuredCloneData>* aRetVal) override;
virtual bool RecvAsyncMessage(const nsString& aMessage,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
@ -444,10 +447,10 @@ public:
protected:
bool ReceiveMessage(const nsString& aMessage,
bool aSync,
StructuredCloneIPCHelper* aHelper,
ipc::StructuredCloneData* aData,
mozilla::jsipc::CpowHolder* aCpows,
nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aJSONRetVal = nullptr);
nsTArray<ipc::StructuredCloneData>* aJSONRetVal = nullptr);
virtual bool RecvAsyncAuthPrompt(const nsCString& aUri,
const nsString& aRealm,

View File

@ -19,6 +19,7 @@ EXPORTS.mozilla.dom.ipc += [
'BlobParent.h',
'IdType.h',
'nsIRemoteBlob.h',
'StructuredCloneData.h',
]
EXPORTS.mozilla.dom += [
@ -37,7 +38,6 @@ EXPORTS.mozilla.dom += [
'NuwaChild.h',
'NuwaParent.h',
'PermissionMessageUtils.h',
'StructuredCloneIPCHelper.h',
'TabChild.h',
'TabContext.h',
'TabMessageUtils.h',
@ -70,7 +70,7 @@ UNIFIED_SOURCES += [
'PreallocatedProcessManager.cpp',
'ProcessPriorityManager.cpp',
'ScreenManagerParent.cpp',
'StructuredCloneIPCHelper.cpp',
'StructuredCloneData.cpp',
'TabChild.cpp',
'TabContext.cpp',
'TabMessageUtils.cpp',

View File

@ -10,9 +10,9 @@
#include "mozilla/dom/DOMTypes.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "nsPrintfCString.h"
@ -117,12 +117,12 @@ nsIContentChild::RecvAsyncMessage(const nsString& aMsg,
{
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::GetChildProcessManager();
if (cpm) {
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForChild(aData, helper);
ipc::StructuredCloneData data;
ipc::UnpackClonedMessageDataForChild(aData, data);
CrossProcessCpowHolder cpows(this, aCpows);
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()), nullptr,
aMsg, false, &helper, &cpows, aPrincipal, nullptr);
aMsg, false, &data, &cpows, aPrincipal, nullptr);
}
return true;
}

View File

@ -13,9 +13,9 @@
#include "mozilla/dom/ContentBridgeParent.h"
#include "mozilla/dom/PTabContext.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/dom/ipc/BlobParent.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/unused.h"
@ -187,7 +187,7 @@ nsIContentParent::RecvSyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals)
nsTArray<ipc::StructuredCloneData>* aRetvals)
{
// FIXME Permission check in Content process
nsIPrincipal* principal = aPrincipal;
@ -201,12 +201,12 @@ nsIContentParent::RecvSyncMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForParent(aData, helper);
ipc::StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
CrossProcessCpowHolder cpows(this, aCpows);
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()), nullptr,
aMsg, true, &helper, &cpows, aPrincipal, aRetvals);
aMsg, true, &data, &cpows, aPrincipal, aRetvals);
}
return true;
}
@ -216,7 +216,7 @@ nsIContentParent::RecvRpcMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals)
nsTArray<ipc::StructuredCloneData>* aRetvals)
{
// FIXME Permission check in Content process
nsIPrincipal* principal = aPrincipal;
@ -230,12 +230,12 @@ nsIContentParent::RecvRpcMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForParent(aData, helper);
ipc::StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
CrossProcessCpowHolder cpows(this, aCpows);
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()), nullptr,
aMsg, true, &helper, &cpows, aPrincipal, aRetvals);
aMsg, true, &data, &cpows, aPrincipal, aRetvals);
}
return true;
}
@ -258,12 +258,12 @@ nsIContentParent::RecvAsyncMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
StructuredCloneIPCHelper helper;
ipc::UnpackClonedMessageDataForParent(aData, helper);
ipc::StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
CrossProcessCpowHolder cpows(this, aCpows);
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()), nullptr,
aMsg, false, &helper, &cpows, aPrincipal, nullptr);
aMsg, false, &data, &cpows, aPrincipal, nullptr);
}
return true;
}

View File

@ -102,12 +102,12 @@ protected: // IPDL methods
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals);
nsTArray<ipc::StructuredCloneData>* aRetvals);
virtual bool RecvRpcMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<StructuredCloneIPCHelper>* aRetvals);
nsTArray<ipc::StructuredCloneData>* aRetvals);
virtual bool RecvAsyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,

View File

@ -64,7 +64,7 @@ private:
nsCOMPtr<nsIWorkerHolder> mWifiWorker;
nsRefPtr<ipc::KeyStore> mKeyStore;
nsRefPtr<mozilla::ipc::KeyStore> mKeyStore;
bool mShutdown;
};

View File

@ -12,7 +12,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/StructuredCloneIPCHelper.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/Maybe.h"
#include "mozilla/TimeStamp.h"
#ifdef XP_WIN
@ -698,9 +698,9 @@ struct ParamTraits<mozilla::TimeStampValue>
#endif
template <>
struct ParamTraits<mozilla::dom::StructuredCloneIPCHelper>
struct ParamTraits<mozilla::dom::ipc::StructuredCloneData>
{
typedef mozilla::dom::StructuredCloneIPCHelper paramType;
typedef mozilla::dom::ipc::StructuredCloneData paramType;
static void Write(Message* aMsg, const paramType& aParam)
{

View File

@ -2942,7 +2942,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
ExprMemberInit(p.lastActorIdVar(),
[ p.actorIdInit(self.side) ]),
ExprMemberInit(p.otherPidVar(),
[ ExprVar('ipc::kInvalidProcessId') ]),
[ ExprVar('mozilla::ipc::kInvalidProcessId') ]),
ExprMemberInit(p.lastShmemIdVar(),
[ p.shmemIdInit(self.side) ]),
ExprMemberInit(p.stateVar(),

View File

@ -4557,7 +4557,7 @@ inline static mozilla::HangMonitor::ActivityType ActivityTypeForMessage(UINT msg
// and http://msdn.microsoft.com/en-us/library/ms633573%28VS.85%29.aspx
LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ipc::CancelCPOWs();
mozilla::ipc::CancelCPOWs();
HangMonitor::NotifyActivity(ActivityTypeForMessage(msg));