Bug 1174461 - [e10s] Return a cached result from SendGetNativePluginPort (r=jimm) a=kwierso

MozReview-Commit-ID: FyeWtg0Py5p

--HG--
extra : source : 0f2e90feea3b779e6b8cc8ca572c6313e1d0995e
This commit is contained in:
Bill McCloskey 2016-03-11 20:25:59 -08:00
Родитель 589e55acf0
Коммит 19aec8471c
3 изменённых файлов: 18 добавлений и 12 удалений

Просмотреть файл

@ -35,7 +35,8 @@ NS_IMPL_ISUPPORTS_INHERITED(PluginWidgetProxy, PuppetWidget, nsIWidget)
PluginWidgetProxy::PluginWidgetProxy(dom::TabChild* aTabChild,
mozilla::plugins::PluginWidgetChild* aActor) :
PuppetWidget(aTabChild),
mActor(aActor)
mActor(aActor),
mCachedPluginPort(0)
{
// See ChannelDestroyed() in the header
mActor->SetWidget(this);
@ -63,6 +64,7 @@ PluginWidgetProxy::Create(nsIWidget* aParent,
}
BaseCreate(aParent, aInitData);
mParent = aParent;
mBounds = aRect;
mEnabled = true;
@ -74,8 +76,6 @@ PluginWidgetProxy::Create(nsIWidget* aParent,
NS_IMETHODIMP
PluginWidgetProxy::SetParent(nsIWidget* aNewParent)
{
mParent = aNewParent;
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
nsIWidget* parent = GetParent();
if (parent) {
@ -84,6 +84,7 @@ PluginWidgetProxy::SetParent(nsIWidget* aNewParent)
if (aNewParent) {
aNewParent->AddChild(this);
}
mParent = aNewParent;
return NS_OK;
}
@ -135,10 +136,14 @@ PluginWidgetProxy::GetNativeData(uint32_t aDataType)
NS_WARNING("PluginWidgetProxy::GetNativeData received request for unsupported data type.");
return nullptr;
}
uintptr_t value = 0;
mActor->SendGetNativePluginPort(&value);
PWLOG("PluginWidgetProxy::GetNativeData %p\n", (void*)value);
return (void*)value;
// The parent side window handle or xid never changes so we can
// cache this for our lifetime.
if (mCachedPluginPort) {
return (void*)mCachedPluginPort;
}
mActor->SendGetNativePluginPort(&mCachedPluginPort);
PWLOG("PluginWidgetProxy::GetNativeData %p\n", (void*)mCachedPluginPort);
return (void*)mCachedPluginPort;
}
#if defined(XP_WIN)

Просмотреть файл

@ -67,6 +67,7 @@ private:
// PuppetWidget does not implement parent apis, but we need
// them for plugin widgets.
nsCOMPtr<nsIWidget> mParent;
uintptr_t mCachedPluginPort;
};
} // namespace widget

Просмотреть файл

@ -592,15 +592,15 @@ double nsIWidget::DefaultScaleOverride()
//-------------------------------------------------------------------------
void nsBaseWidget::AddChild(nsIWidget* aChild)
{
NS_PRECONDITION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(),
"aChild not properly removed from its old child list");
MOZ_RELEASE_ASSERT(!aChild->GetNextSibling() && !aChild->GetPrevSibling(),
"aChild not properly removed from its old child list");
if (!mFirstChild) {
mFirstChild = mLastChild = aChild;
} else {
// append to the list
NS_ASSERTION(mLastChild, "Bogus state");
NS_ASSERTION(!mLastChild->GetNextSibling(), "Bogus state");
MOZ_RELEASE_ASSERT(mLastChild);
MOZ_RELEASE_ASSERT(!mLastChild->GetNextSibling());
mLastChild->SetNextSibling(aChild);
aChild->SetPrevSibling(mLastChild);
mLastChild = aChild;
@ -622,7 +622,7 @@ void nsBaseWidget::RemoveChild(nsIWidget* aChild)
nsIWidget* parent = aChild->GetParent();
NS_ASSERTION(!parent || parent == this, "Not one of our kids!");
#else
NS_ASSERTION(aChild->GetParent() == this, "Not one of our kids!");
MOZ_RELEASE_ASSERT(aChild->GetParent() == this, "Not one of our kids!");
#endif
#endif