Bug 1073597, part 3 - Lazify creation of the CPOW manager in CpowIdHolder. r=billm

This commit is contained in:
Andrew McCreight 2014-10-06 15:45:42 -07:00
parent c060d69f53
commit e9c544cb0a
7 changed files with 28 additions and 15 deletions

View File

@ -1731,7 +1731,7 @@ ContentChild::RecvAsyncMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::sChildProcessManager;
if (cpm) {
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForChild(aData);
CpowIdHolder cpows(GetCPOWManager(), aCpows);
CpowIdHolder cpows(this, aCpows);
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
aMsg, false, &cloneData, &cpows, aPrincipal, nullptr);
}

View File

@ -2574,7 +2574,7 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
StructuredCloneData cloneData = UnpackClonedMessageDataForChild(aData);
nsRefPtr<nsFrameMessageManager> mm =
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
CpowIdHolder cpows(Manager(), aCpows);
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal),
aMessage, false, &cloneData, &cpows, aPrincipal, nullptr);
}

View File

@ -1114,7 +1114,7 @@ TabParent::RecvSyncMessage(const nsString& aMessage,
}
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
CpowIdHolder cpows(Manager(), aCpows);
return ReceiveMessage(aMessage, true, &cloneData, &cpows, aPrincipal, aJSONRetVal);
}
@ -1136,7 +1136,7 @@ TabParent::AnswerRpcMessage(const nsString& aMessage,
}
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
CpowIdHolder cpows(Manager(), aCpows);
return ReceiveMessage(aMessage, true, &cloneData, &cpows, aPrincipal, aJSONRetVal);
}
@ -1157,7 +1157,7 @@ TabParent::RecvAsyncMessage(const nsString& aMessage,
}
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
CpowIdHolder cpows(Manager(), aCpows);
return ReceiveMessage(aMessage, false, &cloneData, &cpows, aPrincipal, nullptr);
}

View File

@ -120,7 +120,7 @@ nsIContentChild::RecvAsyncMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::sChildProcessManager;
if (cpm) {
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForChild(aData);
CpowIdHolder cpows(GetCPOWManager(), aCpows);
CpowIdHolder cpows(this, aCpows);
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
aMsg, false, &cloneData, &cpows, aPrincipal, nullptr);
}

View File

@ -185,8 +185,7 @@ nsIContentParent::RecvSyncMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(GetCPOWManager(), aCpows);
CpowIdHolder cpows(this, aCpows);
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
aMsg, true, &cloneData, &cpows, aPrincipal, aRetvals);
}
@ -213,7 +212,7 @@ nsIContentParent::AnswerRpcMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(GetCPOWManager(), aCpows);
CpowIdHolder cpows(this, aCpows);
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
aMsg, true, &cloneData, &cpows, aPrincipal, aRetvals);
}
@ -239,7 +238,7 @@ nsIContentParent::RecvAsyncMessage(const nsString& aMsg,
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(GetCPOWManager(), aCpows);
CpowIdHolder cpows(this, aCpows);
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
aMsg, false, &cloneData, &cpows, aPrincipal, nullptr);
}

View File

@ -7,6 +7,7 @@
#include "JavaScriptShared.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CPOWManagerGetter.h"
#include "mozilla/dom/TabChild.h"
#include "jsfriendapi.h"
#include "xpcprivate.h"
@ -515,9 +516,21 @@ JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
return true;
}
CpowIdHolder::CpowIdHolder(dom::CPOWManagerGetter *managerGetter, const InfallibleTArray<CpowEntry> &cpows)
: js_(nullptr),
cpows_(cpows)
{
// Only instantiate the CPOW manager if we might need it later.
if (cpows.Length())
js_ = managerGetter->GetCPOWManager();
}
bool
CpowIdHolder::ToObject(JSContext *cx, JS::MutableHandleObject objp)
{
if (!cpows_.Length())
return true;
return js_->Unwrap(cx, cpows_, objp);
}

View File

@ -14,6 +14,11 @@
#include "nsFrameMessageManager.h"
namespace mozilla {
namespace dom {
class CPOWManagerGetter;
}
namespace jsipc {
class ObjectId {
@ -63,11 +68,7 @@ class JavaScriptShared;
class CpowIdHolder : public CpowHolder
{
public:
CpowIdHolder(JavaScriptShared *js, const InfallibleTArray<CpowEntry> &cpows)
: js_(js),
cpows_(cpows)
{
}
CpowIdHolder(dom::CPOWManagerGetter *managerGetter, const InfallibleTArray<CpowEntry> &cpows);
bool ToObject(JSContext *cx, JS::MutableHandleObject objp);