Bug 581341 - Part 4: Always run the IPC testshell callback, regardless of execution success or failure. r=bent

This commit is contained in:
Josh Matthews 2011-06-23 19:31:58 -04:00
parent 552b6b6a78
commit 3e3121d80b
5 changed files with 42 additions and 11 deletions

View File

@ -327,6 +327,14 @@ ContentParent::DestroyTestShell(TestShellParent* aTestShell)
return PTestShellParent::Send__delete__(aTestShell);
}
TestShellParent*
ContentParent::GetTestShellSingleton()
{
if (!ManagedPTestShellParent().Length())
return nsnull;
return static_cast<TestShellParent*>(ManagedPTestShellParent()[0]);
}
ContentParent::ContentParent()
: mGeolocationWatchID(-1)
, mRunToCompletionDepth(0)

View File

@ -94,6 +94,7 @@ public:
TestShellParent* CreateTestShell();
bool DestroyTestShell(TestShellParent* aTestShell);
TestShellParent* GetTestShellSingleton();
void ReportChildAlreadyBlocked();
bool RequestRunToCompletion();

View File

@ -146,3 +146,18 @@ TestShellCommandParent::ReleaseCallback()
{
mCallback.Release();
}
bool
TestShellCommandParent::ExecuteCallback(const nsString& aResponse)
{
return static_cast<TestShellParent*>(Manager())->CommandDone(
this, aResponse);
}
void
TestShellCommandParent::ActorDestroy(ActorDestroyReason why)
{
if (why == AbnormalShutdown) {
ExecuteCallback(EmptyString());
}
}

View File

@ -92,9 +92,12 @@ public:
void ReleaseCallback();
protected:
bool ExecuteCallback(const nsString& aResponse);
void ActorDestroy(ActorDestroyReason why);
bool Recv__delete__(const nsString& aResponse) {
return static_cast<TestShellParent*>(Manager())->CommandDone(
this, aResponse);
return ExecuteCallback(aResponse);
}
private:

View File

@ -706,16 +706,18 @@ XRE_ShutdownChildProcess()
}
namespace {
TestShellParent* gTestShellParent = nsnull;
TestShellParent* GetOrCreateTestShellParent()
{
if (!gTestShellParent) {
ContentParent* parent = ContentParent::GetSingleton();
NS_ENSURE_TRUE(parent, nsnull);
gTestShellParent = parent->CreateTestShell();
NS_ENSURE_TRUE(gTestShellParent, nsnull);
ContentParent* parent = ContentParent::GetSingleton();
if (!parent) {
return nsnull;
}
return gTestShellParent;
TestShellParent* testShell = parent->GetTestShellSingleton();
if (testShell) {
return testShell;
}
testShell = parent->CreateTestShell();
return testShell;
}
}
@ -754,9 +756,11 @@ XRE_GetChildGlobalObject(JSContext* aCx, JSObject** aGlobalP)
bool
XRE_ShutdownTestShell()
{
if (!gTestShellParent)
ContentParent* cp = ContentParent::GetSingleton(PR_FALSE);
TestShellParent* tsp = cp ? cp->GetTestShellSingleton() : nsnull;
if (!tsp)
return true;
return ContentParent::GetSingleton()->DestroyTestShell(gTestShellParent);
return cp->DestroyTestShell(tsp);
}
#ifdef MOZ_X11