Bug 1102060 - Part2: Change the way to send/rcv for ScreenForBrowser. r=smaug
authorchunminchang <cchang@mozilla.com>
Tue, 03 Feb 2015 16:03:28 +0800
changeset 227236 e66dca57463b08efa95b4471421e999a932e9417
parent 227235 fd8292a2ed7bc9f5fa7b82a82dc0d4e371fc4008
child 227237 f9101e882c96053fc948ea6dbdf7a21afd896243
push id28225
push userryanvm@gmail.com
push dateTue, 03 Feb 2015 21:15:47 +0000
treeherdermozilla-central@0c2f7434c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1102060
milestone38.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 1102060 - Part2: Change the way to send/rcv for ScreenForBrowser. r=smaug
dom/ipc/PScreenManager.ipdl
dom/ipc/ScreenManagerParent.cpp
dom/ipc/ScreenManagerParent.h
widget/nsScreenManagerProxy.cpp
--- a/dom/ipc/PScreenManager.ipdl
+++ b/dom/ipc/PScreenManager.ipdl
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBrowser;
 include protocol PContent;
 
 include "mozilla/GfxMessageUtils.h";
 
 using struct nsIntRect from "nsRect.h";
+using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
 
 namespace mozilla {
 namespace dom {
 
 struct ScreenDetails {
   uint32_t id;
   nsIntRect rect;
   nsIntRect rectDisplayPix;
@@ -44,17 +45,17 @@ parent:
 
     prio(high) sync ScreenForRect(int32_t aLeft,
                        int32_t aTop,
                        int32_t aWidth,
                        int32_t aHeight)
       returns (ScreenDetails screen,
                bool success);
 
-    prio(high) sync ScreenForBrowser(PBrowser aBrowser)
+    prio(high) sync ScreenForBrowser(TabId aTabId)
       returns (ScreenDetails screen,
                bool success);
 
 child:
     __delete__();
 };
 
 } // namespace dom
--- a/dom/ipc/ScreenManagerParent.cpp
+++ b/dom/ipc/ScreenManagerParent.cpp
@@ -4,16 +4,17 @@
  * 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 "mozilla/dom/TabParent.h"
 #include "mozilla/unused.h"
 #include "nsIWidget.h"
 #include "nsServiceManagerUtils.h"
 #include "ScreenManagerParent.h"
+#include "ContentProcessManager.h"
 
 namespace mozilla {
 namespace dom {
 
 static const char *sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1";
 
 ScreenManagerParent::ScreenManagerParent(uint32_t* aNumberOfScreens,
                                          float* aSystemDefaultScale,
@@ -111,30 +112,37 @@ ScreenManagerParent::RecvScreenForRect(c
   }
 
   *aRetVal = details;
   *aSuccess = true;
   return true;
 }
 
 bool
-ScreenManagerParent::RecvScreenForBrowser(PBrowserParent* aBrowser,
+ScreenManagerParent::RecvScreenForBrowser(const TabId& aTabId,
                                           ScreenDetails* aRetVal,
                                           bool* aSuccess)
 {
   *aSuccess = false;
 #ifdef MOZ_VALGRIND
   // Zero this so that Valgrind doesn't complain when we send it to another
   // process.
   memset(aRetVal, 0, sizeof(ScreenDetails));
 #endif
 
   // Find the mWidget associated with the tabparent, and then return
   // the nsIScreen it's on.
-  TabParent* tabParent = static_cast<TabParent*>(aBrowser);
+  ContentParent* cp = static_cast<ContentParent*>(this->Manager());
+  ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
+  nsRefPtr<TabParent> tabParent =
+    cpm->GetTopLevelTabParentByProcessAndTabId(cp->ChildID(), aTabId);
+  if(!tabParent){
+    return false;
+  }
+
   nsCOMPtr<nsIWidget> widget = tabParent->GetWidget();
 
   nsCOMPtr<nsIScreen> screen;
   if (widget) {
     if (widget->GetNativeData(NS_NATIVE_WINDOW)) {
       mScreenMgr->ScreenForNativeWidget(widget->GetNativeData(NS_NATIVE_WINDOW),
                                         getter_AddRefs(screen));
     }
--- a/dom/ipc/ScreenManagerParent.h
+++ b/dom/ipc/ScreenManagerParent.h
@@ -36,17 +36,17 @@ class ScreenManagerParent : public PScre
 
   virtual bool RecvScreenForRect(const int32_t& aLeft,
                                  const int32_t& aTop,
                                  const int32_t& aWidth,
                                  const int32_t& aHeight,
                                  ScreenDetails* aRetVal,
                                  bool* aSuccess) MOZ_OVERRIDE;
 
-  virtual bool RecvScreenForBrowser(PBrowserParent* aBrowser,
+  virtual bool RecvScreenForBrowser(const TabId& aTabId,
                                     ScreenDetails* aRetVal,
                                     bool* aSuccess) MOZ_OVERRIDE;
 
  private:
   bool ExtractScreenDetails(nsIScreen* aScreen, ScreenDetails &aDetails);
   nsCOMPtr<nsIScreenManager> mScreenMgr;
 };
 
--- a/widget/nsScreenManagerProxy.cpp
+++ b/widget/nsScreenManagerProxy.cpp
@@ -121,17 +121,17 @@ nsScreenManagerProxy::ScreenForNativeWid
           return NS_OK;
       }
   }
 
   // Never cached this screen, so we have to ask the parent process
   // for it.
   bool success = false;
   ScreenDetails details;
-  unused << SendScreenForBrowser(tabChild, &details, &success);
+  unused << SendScreenForBrowser(tabChild->GetTabId(), &details, &success);
   if (!success) {
     return NS_ERROR_FAILURE;
   }
 
   ScreenCacheEntry newEntry;
   nsRefPtr<ScreenProxy> screen = new ScreenProxy(this, details);
 
   newEntry.mScreenProxy = screen;