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

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

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

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

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