Bug 1174461 - [e10s] Return a cached result from SendGetNativePluginPort (r=jimm)
☠☠ backed out by 39e3c3e2970e ☠ ☠
authorBill McCloskey <billm@mozilla.com>
Fri, 11 Mar 2016 20:25:59 -0800
changeset 328898 0f2e90feea3b779e6b8cc8ca572c6313e1d0995e
parent 328897 08a097c4ea862f80c537d784de3635e1dcbf0f70
child 328899 6c8278e8047ee59720ecafffe1a3c568e10a22e7
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1174461
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1174461 - [e10s] Return a cached result from SendGetNativePluginPort (r=jimm)
widget/PluginWidgetProxy.cpp
widget/PluginWidgetProxy.h
widget/nsBaseWidget.cpp
--- a/widget/PluginWidgetProxy.cpp
+++ b/widget/PluginWidgetProxy.cpp
@@ -30,17 +30,18 @@ NS_IMPL_ISUPPORTS_INHERITED(PluginWidget
     NS_WARNING("called on an invalid channel.");              \
     return NS_ERROR_FAILURE;                                  \
   }                                                           \
 } while (0)
 
 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);
 }
 
 PluginWidgetProxy::~PluginWidgetProxy()
 {
   PWLOG("PluginWidgetProxy::~PluginWidgetProxy()\n");
@@ -58,37 +59,37 @@ PluginWidgetProxy::Create(nsIWidget* aPa
   nsresult rv = NS_ERROR_UNEXPECTED;
   mActor->SendCreate(&rv);
   if (NS_FAILED(rv)) {
     NS_WARNING("failed to create chrome widget, plugins won't paint.");
     return rv;
   }
 
   BaseCreate(aParent, aInitData);
+  mParent = aParent;
 
   mBounds = aRect;
   mEnabled = true;
   mVisible = true;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PluginWidgetProxy::SetParent(nsIWidget* aNewParent)
 {
-  mParent = aNewParent;
-
   nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
   nsIWidget* parent = GetParent();
   if (parent) {
     parent->RemoveChild(this);
   }
   if (aNewParent) {
     aNewParent->AddChild(this);
   }
+  mParent = aNewParent;
   return NS_OK;
 }
 
 nsIWidget*
 PluginWidgetProxy::GetParent(void)
 {
   return mParent.get();
 }
@@ -130,20 +131,24 @@ PluginWidgetProxy::GetNativeData(uint32_
     case NS_NATIVE_PLUGIN_PORT:
     case NS_NATIVE_WINDOW:
     case NS_NATIVE_SHAREABLE_WINDOW:
       break;
     default:
       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)
 void
 PluginWidgetProxy::SetNativeData(uint32_t aDataType, uintptr_t aVal)
 {
   if (!mActor) {
     return;
--- a/widget/PluginWidgetProxy.h
+++ b/widget/PluginWidgetProxy.h
@@ -62,14 +62,15 @@ public:
   void ChannelDestroyed() { mActor = nullptr; }
 
 private:
   // Our connection with the chrome widget, created on PBrowser.
   mozilla::plugins::PluginWidgetChild* mActor;
   // PuppetWidget does not implement parent apis, but we need
   // them for plugin widgets.
   nsCOMPtr<nsIWidget> mParent;
+  uintptr_t mCachedPluginPort;
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -587,25 +587,25 @@ double nsIWidget::DefaultScaleOverride()
 
 //-------------------------------------------------------------------------
 //
 // Add a child to the list of children
 //
 //-------------------------------------------------------------------------
 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;
   }
 }
 
 
 //-------------------------------------------------------------------------
@@ -617,17 +617,17 @@ void nsBaseWidget::RemoveChild(nsIWidget
 {
 #ifdef DEBUG
 #ifdef XP_MACOSX
   // nsCocoaWindow doesn't implement GetParent, so in that case parent will be
   // null and we'll just have to do without this assertion.
   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
 
   if (mLastChild == aChild) {
     mLastChild = mLastChild->GetPrevSibling();
   }
   if (mFirstChild == aChild) {
     mFirstChild = mFirstChild->GetNextSibling();