Bug 669640 - Fix the message manager API to work with multiple content processes, r=bsmedberg

--HG--
extra : rebase_source : bdb66e3f1a9a956d80b2e01869a7ed15b3710c0e
This commit is contained in:
Olli Pettay 2011-08-02 15:57:48 -04:00
Родитель da5f2e8b5b 46b695e56b
Коммит d4a720b816
14 изменённых файлов: 180 добавлений и 82 удалений

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

@ -118,8 +118,15 @@ interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
[notxpcom] nsIContent getOwnerContent(); [notxpcom] nsIContent getOwnerContent();
}; };
[scriptable, uuid(ed6522fd-ffb6-4920-b50d-cf629309616b)] [scriptable, uuid(6331bbca-2c9f-4766-b3c7-ae75554bf1ec)]
interface nsIChromeFrameMessageManager : nsIFrameMessageManager interface nsITreeItemFrameMessageManager : nsIFrameMessageManager
{
readonly attribute unsigned long childCount;
nsITreeItemFrameMessageManager getChildAt(in unsigned long aIndex);
};
[scriptable, uuid(23e6ef7b-8cc5-4e8b-9391-453440a3b858)]
interface nsIChromeFrameMessageManager : nsITreeItemFrameMessageManager
{ {
/* /*
* Load a script in the (remote) frame. aURL must be the absolute URL. * Load a script in the (remote) frame. aURL must be the absolute URL.

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

@ -1791,7 +1791,7 @@ nsFrameLoader::TryRemoteBrowser()
return false; return false;
} }
ContentParent* parent = ContentParent::GetSingleton(); ContentParent* parent = ContentParent::GetNewOrUsed();
NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!"); NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!");
mRemoteBrowser = parent->CreateTab(chromeFlags); mRemoteBrowser = parent->CreateTab(chromeFlags);
if (mRemoteBrowser) { if (mRemoteBrowser) {

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

@ -98,6 +98,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
!mChrome && !mIsProcessManager) !mChrome && !mIsProcessManager)
/* Message managers in child process support nsISyncMessageSender. */ /* Message managers in child process support nsISyncMessageSender. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISyncMessageSender, !mChrome) NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISyncMessageSender, !mChrome)
/* Message managers in chrome process support nsITreeItemFrameMessageManager. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsITreeItemFrameMessageManager, mChrome)
/* Process message manager doesn't support nsIChromeFrameMessageManager. */ /* Process message manager doesn't support nsIChromeFrameMessageManager. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIChromeFrameMessageManager, NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIChromeFrameMessageManager,
mChrome && !mIsProcessManager) mChrome && !mIsProcessManager)
@ -323,6 +325,24 @@ nsFrameMessageManager::GetDocShell(nsIDocShell** aDocShell)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsFrameMessageManager::GetChildCount(PRUint32* aChildCount)
{
*aChildCount = static_cast<PRUint32>(mChildManagers.Count());
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::GetChildAt(PRUint32 aIndex,
nsITreeItemFrameMessageManager** aMM)
{
*aMM = nsnull;
nsCOMPtr<nsITreeItemFrameMessageManager> mm =
do_QueryInterface(mChildManagers.SafeObjectAt(static_cast<PRUint32>(aIndex)));
mm.swap(*aMM);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsFrameMessageManager::Btoa(const nsAString& aBinaryData, nsFrameMessageManager::Btoa(const nsAString& aBinaryData,
nsAString& aAsciiBase64String) nsAString& aAsciiBase64String)
@ -823,7 +843,7 @@ bool SendAsyncMessageToChildProcess(void* aCallbackData,
const nsAString& aJSON) const nsAString& aJSON)
{ {
mozilla::dom::ContentParent* cp = mozilla::dom::ContentParent* cp =
mozilla::dom::ContentParent::GetSingleton(PR_FALSE); static_cast<mozilla::dom::ContentParent*>(aCallbackData);
NS_WARN_IF_FALSE(cp, "No child process!"); NS_WARN_IF_FALSE(cp, "No child process!");
if (cp) { if (cp) {
return cp->SendAsyncMessage(nsString(aMessage), nsString(aJSON)); return cp->SendAsyncMessage(nsString(aMessage), nsString(aJSON));
@ -857,6 +877,7 @@ bool SendAsyncMessageToParentProcess(void* aCallbackData,
return true; return true;
} }
// This creates the global parent process message manager.
nsresult nsresult
NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult) NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult)
{ {
@ -865,9 +886,9 @@ NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult)
NS_ENSURE_TRUE(IsChromeProcess(), NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(IsChromeProcess(), NS_ERROR_NOT_AVAILABLE);
nsFrameMessageManager* mm = new nsFrameMessageManager(PR_TRUE, nsFrameMessageManager* mm = new nsFrameMessageManager(PR_TRUE,
nsnull, nsnull,
SendAsyncMessageToChildProcess,
nsnull, nsnull,
&nsFrameMessageManager::sParentProcessManager, nsnull,
nsnull,
nsnull, nsnull,
nsnull, nsnull,
PR_FALSE, PR_FALSE,
@ -877,6 +898,25 @@ NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult)
return CallQueryInterface(mm, aResult); return CallQueryInterface(mm, aResult);
} }
nsFrameMessageManager*
nsFrameMessageManager::NewProcessMessageManager(mozilla::dom::ContentParent* aProcess)
{
if (!nsFrameMessageManager::sParentProcessManager) {
nsCOMPtr<nsIFrameMessageManager> dummy;
NS_NewParentProcessMessageManager(getter_AddRefs(dummy));
}
nsFrameMessageManager* mm = new nsFrameMessageManager(PR_TRUE,
nsnull,
SendAsyncMessageToChildProcess,
nsnull,
aProcess,
nsFrameMessageManager::sParentProcessManager,
nsnull,
PR_FALSE,
PR_TRUE);
return mm;
}
nsresult nsresult
NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult) NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)

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

@ -52,6 +52,12 @@
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
namespace mozilla {
namespace dom {
class ContentParent;
}
}
class nsAXPCNativeCallContext; class nsAXPCNativeCallContext;
struct JSContext; struct JSContext;
struct JSObject; struct JSObject;
@ -125,6 +131,10 @@ public:
NS_DECL_NSISYNCMESSAGESENDER NS_DECL_NSISYNCMESSAGESENDER
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
NS_DECL_NSICHROMEFRAMEMESSAGEMANAGER NS_DECL_NSICHROMEFRAMEMESSAGEMANAGER
NS_DECL_NSITREEITEMFRAMEMESSAGEMANAGER
static nsFrameMessageManager*
NewProcessMessageManager(mozilla::dom::ContentParent* aProcess);
nsresult ReceiveMessage(nsISupports* aTarget, const nsAString& aMessage, nsresult ReceiveMessage(nsISupports* aTarget, const nsAString& aMessage,
PRBool aSync, const nsAString& aJSON, PRBool aSync, const nsAString& aJSON,

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

@ -44,6 +44,7 @@
#include "History.h" #include "History.h"
#include "mozilla/ipc/TestShellParent.h" #include "mozilla/ipc/TestShellParent.h"
#include "mozilla/net/NeckoParent.h" #include "mozilla/net/NeckoParent.h"
#include "mozilla/Preferences.h"
#include "nsHashPropertyBag.h" #include "nsHashPropertyBag.h"
#include "nsIFilePicker.h" #include "nsIFilePicker.h"
#include "nsIWindowWatcher.h" #include "nsIWindowWatcher.h"
@ -111,6 +112,7 @@
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
static const char* sClipboardTextFlavors[] = { kUnicodeMime }; static const char* sClipboardTextFlavors[] = { kUnicodeMime };
using mozilla::Preferences;
using namespace mozilla::ipc; using namespace mozilla::ipc;
using namespace mozilla::net; using namespace mozilla::net;
using namespace mozilla::places; using namespace mozilla::places;
@ -154,21 +156,39 @@ MemoryReportRequestParent::~MemoryReportRequestParent()
MOZ_COUNT_DTOR(MemoryReportRequestParent); MOZ_COUNT_DTOR(MemoryReportRequestParent);
} }
ContentParent* ContentParent::gSingleton; nsTArray<ContentParent*>* ContentParent::gContentParents;
ContentParent* ContentParent*
ContentParent::GetSingleton(PRBool aForceNew) ContentParent::GetNewOrUsed()
{ {
if (gSingleton && !gSingleton->IsAlive()) if (!gContentParents)
gSingleton = nsnull; gContentParents = new nsTArray<ContentParent*>();
if (!gSingleton && aForceNew) { PRInt32 maxContentProcesses = Preferences::GetInt("dom.ipc.processCount", 1);
nsRefPtr<ContentParent> parent = new ContentParent(); if (maxContentProcesses < 1)
gSingleton = parent; maxContentProcesses = 1;
parent->Init();
if (gContentParents->Length() >= PRUint32(maxContentProcesses)) {
ContentParent* p = (*gContentParents)[rand() % gContentParents->Length()];
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in gContentParents?");
return p;
}
nsRefPtr<ContentParent> p = new ContentParent();
p->Init();
gContentParents->AppendElement(p);
return p;
}
void
ContentParent::GetAll(nsTArray<ContentParent*>& aArray)
{
if (!gContentParents) {
aArray.Clear();
return;
} }
return gSingleton; aArray = *gContentParents;
} }
void void
@ -195,7 +215,7 @@ ContentParent::Init()
threadInt->SetObserver(this); threadInt->SetObserver(this);
} }
if (obs) { if (obs) {
obs->NotifyObservers(nsnull, "ipc:content-created", nsnull); obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", nsnull);
} }
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY
@ -274,6 +294,8 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
#endif #endif
} }
mMessageManager->Disconnect();
// clear the child memory reporters // clear the child memory reporters
InfallibleTArray<MemoryReport> empty; InfallibleTArray<MemoryReport> empty;
SetChildMemoryReporters(empty); SetChildMemoryReporters(empty);
@ -295,6 +317,14 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
if (mRunToCompletionDepth) if (mRunToCompletionDepth)
mRunToCompletionDepth = 0; mRunToCompletionDepth = 0;
if (gContentParents) {
gContentParents->RemoveElement(this);
if (!gContentParents->Length()) {
delete gContentParents;
gContentParents = NULL;
}
}
mIsAlive = false; mIsAlive = false;
if (obs) { if (obs) {
@ -362,6 +392,7 @@ ContentParent::ContentParent()
, mShouldCallUnblockChild(false) , mShouldCallUnblockChild(false)
, mIsAlive(true) , mIsAlive(true)
, mProcessStartTime(time(NULL)) , mProcessStartTime(time(NULL))
, mSendPermissionUpdates(false)
{ {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content); mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content);
@ -372,6 +403,7 @@ ContentParent::ContentParent()
nsChromeRegistryChrome* chromeRegistry = nsChromeRegistryChrome* chromeRegistry =
static_cast<nsChromeRegistryChrome*>(registrySvc.get()); static_cast<nsChromeRegistryChrome*>(registrySvc.get());
chromeRegistry->SendRegisteredChrome(this); chromeRegistry->SendRegisteredChrome(this);
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
} }
ContentParent::~ContentParent() ContentParent::~ContentParent()
@ -380,10 +412,8 @@ ContentParent::~ContentParent()
base::CloseProcessHandle(OtherProcess()); base::CloseProcessHandle(OtherProcess());
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
//If the previous content process has died, a new one could have NS_ASSERTION(!gContentParents || !gContentParents->Contains(this),
//been started since. "Should have been removed in ActorDestroy");
if (gSingleton == this)
gSingleton = nsnull;
} }
bool bool
@ -459,7 +489,7 @@ ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissio
} }
// Ask for future changes // Ask for future changes
permissionManager->ChildRequestPermissions(); mSendPermissionUpdates = true;
#endif #endif
return true; return true;
@ -1062,7 +1092,7 @@ bool
ContentParent::RecvSyncMessage(const nsString& aMsg, const nsString& aJSON, ContentParent::RecvSyncMessage(const nsString& aMsg, const nsString& aJSON,
InfallibleTArray<nsString>* aRetvals) InfallibleTArray<nsString>* aRetvals)
{ {
nsRefPtr<nsFrameMessageManager> ppm = nsFrameMessageManager::sParentProcessManager; nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) { if (ppm) {
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()), ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
aMsg,PR_TRUE, aJSON, nsnull, aRetvals); aMsg,PR_TRUE, aJSON, nsnull, aRetvals);
@ -1073,7 +1103,7 @@ ContentParent::RecvSyncMessage(const nsString& aMsg, const nsString& aJSON,
bool bool
ContentParent::RecvAsyncMessage(const nsString& aMsg, const nsString& aJSON) ContentParent::RecvAsyncMessage(const nsString& aMsg, const nsString& aJSON)
{ {
nsRefPtr<nsFrameMessageManager> ppm = nsFrameMessageManager::sParentProcessManager; nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) { if (ppm) {
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()), ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
aMsg, PR_FALSE, aJSON, nsnull, nsnull); aMsg, PR_FALSE, aJSON, nsnull, nsnull);

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

@ -55,6 +55,7 @@
#include "nsIMemoryReporter.h" #include "nsIMemoryReporter.h"
#include "nsCOMArray.h" #include "nsCOMArray.h"
class nsFrameMessageManager;
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
@ -77,12 +78,8 @@ private:
typedef mozilla::ipc::TestShellParent TestShellParent; typedef mozilla::ipc::TestShellParent TestShellParent;
public: public:
static ContentParent* GetSingleton(PRBool aForceNew = PR_TRUE); static ContentParent* GetNewOrUsed();
static void GetAll(nsTArray<ContentParent*>& aArray);
#if 0
// TODO: implement this somewhere!
static ContentParent* FreeSingleton();
#endif
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
@ -102,12 +99,16 @@ public:
void SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& report); void SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& report);
bool NeedsPermissionsUpdate() {
return mSendPermissionUpdates;
}
protected: protected:
void OnChannelConnected(int32 pid); void OnChannelConnected(int32 pid);
virtual void ActorDestroy(ActorDestroyReason why); virtual void ActorDestroy(ActorDestroyReason why);
private: private:
static ContentParent* gSingleton; static nsTArray<ContentParent*>* gContentParents;
// Hide the raw constructor methods since we don't want client code // Hide the raw constructor methods since we don't want client code
// using them. // using them.
@ -229,6 +230,10 @@ private:
bool mIsAlive; bool mIsAlive;
nsCOMPtr<nsIPrefServiceInternal> mPrefService; nsCOMPtr<nsIPrefServiceInternal> mPrefService;
time_t mProcessStartTime; time_t mProcessStartTime;
bool mSendPermissionUpdates;
nsRefPtr<nsFrameMessageManager> mMessageManager;
}; };
} // namespace dom } // namespace dom

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

@ -106,14 +106,37 @@
if (!didThrow) { if (!didThrow) {
alert("One shouldn't be able to create content process message manager in chrome process!"); alert("One shouldn't be able to create content process message manager in chrome process!");
} }
var tppm = ppm.QueryInterface(Components.interfaces.nsITreeItemFrameMessageManager);
if (tppm.childCount != 1) {
alert("Should have one child process!");
}
var childprocessmm = tppm.getChildAt(0);
childprocessmm.addMessageListener("ppm-sync",
function(m) {
if (m.target != childprocessmm) alert("Wrong target!");
document.getElementById("messageLog").value += "[SYNC1 PPM]";
}
);
ppm.addMessageListener("ppm-sync", ppm.addMessageListener("ppm-sync",
function(m) { function(m) {
document.getElementById("messageLog").value += "[SYNC PPM]"; // Check that global process message manager gets the per-process mm as target.
if (m.target != childprocessmm) alert("Wrong target!");
document.getElementById("messageLog").value += "[SYNC2 PPM]";
}
);
childprocessmm.addMessageListener("ppm-async",
function(m) {
if (m.target != childprocessmm) alert("Wrong target!");
document.getElementById("messageLog").value += "[ASYNC1 PPM]";
} }
); );
ppm.addMessageListener("ppm-async", ppm.addMessageListener("ppm-async",
function(m) { function(m) {
document.getElementById("messageLog").value += "[ASYNC PPM]"; // Check that global process message manager gets the per-process mm as target.
if (m.target != childprocessmm) alert("Wrong target!");
document.getElementById("messageLog").value += "[ASYNC2 PPM]";
} }
); );
messageManager.loadFrameScript("chrome://global/content/remote-test-ipc.js", true); messageManager.loadFrameScript("chrome://global/content/remote-test-ipc.js", true);

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

@ -89,23 +89,6 @@ ChildProcess()
} }
/**
* @returns The parent process object, or if we are not in the parent
* process, nsnull.
*/
static ContentParent*
ParentProcess()
{
if (!IsChildProcess()) {
ContentParent* cpc = ContentParent::GetSingleton();
if (!cpc)
NS_RUNTIMEABORT("Content Process is NULL!");
return cpc;
}
return nsnull;
}
#define ENSURE_NOT_CHILD_PROCESS_(onError) \ #define ENSURE_NOT_CHILD_PROCESS_(onError) \
PR_BEGIN_MACRO \ PR_BEGIN_MACRO \
if (IsChildProcess()) { \ if (IsChildProcess()) { \
@ -170,7 +153,6 @@ NS_IMPL_ISUPPORTS3(nsPermissionManager, nsIPermissionManager, nsIObserver, nsISu
nsPermissionManager::nsPermissionManager() nsPermissionManager::nsPermissionManager()
: mLargestID(0) : mLargestID(0)
, mUpdateChildProcess(PR_FALSE)
{ {
} }
@ -467,12 +449,16 @@ nsPermissionManager::AddInternal(const nsAFlatCString &aHost,
DBOperationType aDBOperation) DBOperationType aDBOperation)
{ {
if (!IsChildProcess()) { if (!IsChildProcess()) {
// In the parent, send the update now, if the child is ready IPC::Permission permission((aHost),
if (mUpdateChildProcess) { (aType),
IPC::Permission permission((aHost), aPermission, aExpireType, aExpireTime);
(aType),
aPermission, aExpireType, aExpireTime); nsTArray<ContentParent*> cplist;
unused << ParentProcess()->SendAddPermission(permission); ContentParent::GetAll(cplist);
for (PRUint32 i = 0; i < cplist.Length(); ++i) {
ContentParent* cp = cplist[i];
if (cp->NeedsPermissionsUpdate())
unused << cp->SendAddPermission(permission);
} }
} }

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

@ -250,17 +250,6 @@ private:
// An array to store the strings identifying the different types. // An array to store the strings identifying the different types.
nsTArray<nsCString> mTypeArray; nsTArray<nsCString> mTypeArray;
// Whether we should update the child process with every change to a
// permission. This is set to true once the child is ready to receive
// such updates.
PRBool mUpdateChildProcess;
public:
void ChildRequestPermissions()
{
mUpdateChildProcess = PR_TRUE;
}
}; };
// {4F6B5E00-0C36-11d5-A535-0010A401EB10} // {4F6B5E00-0C36-11d5-A535-0010A401EB10}

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

@ -1493,6 +1493,8 @@ pref("dom.ipc.plugins.enabled.602plugin.so", false);
#endif #endif
#endif #endif
pref("dom.ipc.processCount", 1);
pref("svg.smil.enabled", true); pref("svg.smil.enabled", true);
pref("font.minimum-size.ar", 0); pref("font.minimum-size.ar", 0);

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

@ -55,6 +55,7 @@
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIXPConnect.h" #include "nsIXPConnect.h"
#include "mozilla/unused.h"
#include "mozilla/Util.h" #include "mozilla/Util.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
@ -65,6 +66,7 @@
#define TOPIC_UPDATEPLACES_COMPLETE "places-updatePlaces-complete" #define TOPIC_UPDATEPLACES_COMPLETE "places-updatePlaces-complete"
using namespace mozilla::dom; using namespace mozilla::dom;
using mozilla::unused;
namespace mozilla { namespace mozilla {
namespace places { namespace places {
@ -1282,10 +1284,11 @@ History::NotifyVisited(nsIURI* aURI)
nsAutoScriptBlocker scriptBlocker; nsAutoScriptBlocker scriptBlocker;
if (XRE_GetProcessType() == GeckoProcessType_Default) { if (XRE_GetProcessType() == GeckoProcessType_Default) {
mozilla::dom::ContentParent* cpp = nsTArray<ContentParent*> cplist;
mozilla::dom::ContentParent::GetSingleton(PR_FALSE); ContentParent::GetAll(cplist);
if (cpp) for (PRUint32 i = 0; i < cplist.Length(); ++i) {
(void)cpp->SendNotifyVisited(aURI); unused << cplist[i]->SendNotifyVisited(aURI);
}
} }
// If the hash table has not been initialized, then we have nothing to notify // If the hash table has not been initialized, then we have nothing to notify

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

@ -121,6 +121,9 @@
#include "nsAppShellCID.h" #include "nsAppShellCID.h"
#include "mozilla/FunctionTimer.h" #include "mozilla/FunctionTimer.h"
#include "mozilla/unused.h"
using mozilla::unused;
#ifdef XP_WIN #ifdef XP_WIN
#include "nsIWinAppHelper.h" #include "nsIWinAppHelper.h"
@ -755,9 +758,7 @@ nsXULAppInfo::EnsureContentProcess()
if (XRE_GetProcessType() != GeckoProcessType_Default) if (XRE_GetProcessType() != GeckoProcessType_Default)
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
ContentParent* c = ContentParent::GetSingleton(); unused << ContentParent::GetNewOrUsed();
if (!c)
return NS_ERROR_NOT_AVAILABLE;
return NS_OK; return NS_OK;
} }

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

@ -712,7 +712,7 @@ TestShellParent* gTestShellParent = nsnull;
TestShellParent* GetOrCreateTestShellParent() TestShellParent* GetOrCreateTestShellParent()
{ {
if (!gTestShellParent) { if (!gTestShellParent) {
ContentParent* parent = ContentParent::GetSingleton(); ContentParent* parent = ContentParent::GetNewOrUsed();
NS_ENSURE_TRUE(parent, nsnull); NS_ENSURE_TRUE(parent, nsnull);
gTestShellParent = parent->CreateTestShell(); gTestShellParent = parent->CreateTestShell();
NS_ENSURE_TRUE(gTestShellParent, nsnull); NS_ENSURE_TRUE(gTestShellParent, nsnull);
@ -758,7 +758,8 @@ XRE_ShutdownTestShell()
{ {
if (!gTestShellParent) if (!gTestShellParent)
return true; return true;
return ContentParent::GetSingleton()->DestroyTestShell(gTestShellParent); return static_cast<ContentParent*>(gTestShellParent->Manager())->
DestroyTestShell(gTestShellParent);
} }
#ifdef MOZ_X11 #ifdef MOZ_X11

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

@ -95,8 +95,8 @@ class ContentCreationNotifier : public nsIObserver
const PRUnichar* aData) const PRUnichar* aData)
{ {
if (!strcmp(aTopic, "ipc:content-created")) { if (!strcmp(aTopic, "ipc:content-created")) {
ContentParent *cp = ContentParent::GetSingleton(PR_FALSE); nsCOMPtr<nsIObserver> cpo = do_QueryInterface(aSubject);
NS_ABORT_IF_FALSE(cp, "Must have content process if notified of its creation"); ContentParent* cp = static_cast<ContentParent*>(cpo.get());
unused << cp->SendScreenSizeChanged(gAndroidScreenBounds); unused << cp->SendScreenSizeChanged(gAndroidScreenBounds);
} else if (!strcmp(aTopic, "xpcom-shutdown")) { } else if (!strcmp(aTopic, "xpcom-shutdown")) {
nsCOMPtr<nsIObserverService> nsCOMPtr<nsIObserverService>
@ -771,9 +771,10 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
break; break;
// Tell the content process the new screen size. // Tell the content process the new screen size.
ContentParent *cp = ContentParent::GetSingleton(PR_FALSE); nsTArray<ContentParent*> cplist;
if (cp) ContentParent::GetAll(cplist);
unused << cp->SendScreenSizeChanged(gAndroidScreenBounds); for (PRUint32 i = 0; i < cplist.Length(); ++i)
unused << cplist[i]->SendScreenSizeChanged(gAndroidScreenBounds);
if (gContentCreationNotifier) if (gContentCreationNotifier)
break; break;