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
Родитель 812b334553
Коммит 4560199bc4
5 изменённых файлов: 42 добавлений и 11 удалений

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

@ -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)

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

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

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

@ -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());
}
}

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

@ -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:

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

@ -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