Bug 847656: Change ContentParent::GetNewOrUsed to return an already_AddRefed value. r=khuey

This commit is contained in:
Jim Blandy 2013-03-20 10:30:09 -07:00
parent 3be59a99fb
commit 614dfd0dfd
4 changed files with 8 additions and 6 deletions

View File

@ -370,7 +370,7 @@ ContentParent::JoinAllSubprocesses()
sCanLaunchSubprocesses = false;
}
/*static*/ ContentParent*
/*static*/ already_AddRefed<ContentParent>
ContentParent::GetNewOrUsed(bool aForBrowserElement)
{
if (!gNonAppContentParents)
@ -394,7 +394,7 @@ ContentParent::GetNewOrUsed(bool aForBrowserElement)
PROCESS_PRIORITY_FOREGROUND);
p->Init();
gNonAppContentParents->AppendElement(p);
return p;
return p.forget();
}
namespace {
@ -465,7 +465,7 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
}
if (aContext.IsBrowserElement() || !aContext.HasOwnApp()) {
if (ContentParent* cp = GetNewOrUsed(aContext.IsBrowserElement())) {
if (nsRefPtr<ContentParent> cp = GetNewOrUsed(aContext.IsBrowserElement())) {
nsRefPtr<TabParent> tp(new TabParent(aContext));
tp->SetOwnerElement(aFrameElement);
PBrowserParent* browser = cp->SendPBrowserConstructor(

View File

@ -81,7 +81,8 @@ public:
*/
static void JoinAllSubprocesses();
static ContentParent* GetNewOrUsed(bool aForBrowserElement = false);
static already_AddRefed<ContentParent>
GetNewOrUsed(bool aForBrowserElement = false);
/**
* Get or create a content process for the given TabContext. aFrameElement

View File

@ -780,7 +780,7 @@ nsXULAppInfo::EnsureContentProcess()
if (XRE_GetProcessType() != GeckoProcessType_Default)
return NS_ERROR_NOT_AVAILABLE;
unused << ContentParent::GetNewOrUsed();
nsRefPtr<ContentParent> unused = ContentParent::GetNewOrUsed();
return NS_OK;
}

View File

@ -695,7 +695,8 @@ ContentParent* gContentParent; //long-lived, manually refcounted
TestShellParent* GetOrCreateTestShellParent()
{
if (!gContentParent) {
NS_ADDREF(gContentParent = ContentParent::GetNewOrUsed());
nsRefPtr<ContentParent> parent = ContentParent::GetNewOrUsed().get();
parent.forget(&gContentParent);
} else if (!gContentParent->IsAlive()) {
return nullptr;
}