Back out 3 changesets (bug 1103036) for b2g xpcshell bustage

CLOSED TREE

Backed out changeset e6ab63938473 (bug 1103036)
Backed out changeset 900bb5fcdd36 (bug 1103036)
Backed out changeset bc53d85bc1b2 (bug 1103036)
This commit is contained in:
Phil Ringnalda 2015-01-06 23:33:50 -08:00
parent 5d83d7a615
commit dee4a5a699
7 changed files with 32 additions and 139 deletions

View File

@ -2489,20 +2489,6 @@ ContentChild::RecvAssociatePluginId(const uint32_t& aPluginId,
return true;
}
bool
ContentChild::RecvShutdown()
{
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
os->NotifyObservers(this, "content-child-shutdown", nullptr);
}
// Ignore errors here. If this fails, the parent will kill us after a
// timeout.
unused << SendFinishShutdown();
return true;
}
PBrowserOrId
ContentChild::GetBrowserOrId(TabChild* aTabChild)
{

View File

@ -377,7 +377,6 @@ public:
const nsTArray<nsCString>& aThreadNameFilters) MOZ_OVERRIDE;
virtual bool RecvStopProfiler() MOZ_OVERRIDE;
virtual bool RecvGetProfile(nsCString* aProfile) MOZ_OVERRIDE;
virtual bool RecvShutdown() MOZ_OVERRIDE;
#ifdef ANDROID
gfxIntSize GetScreenSize() { return mScreenSize; }

View File

@ -116,7 +116,6 @@
#include "nsISpellChecker.h"
#include "nsIStyleSheet.h"
#include "nsISupportsPrimitives.h"
#include "nsITimer.h"
#include "nsIURIFixup.h"
#include "nsIWindowWatcher.h"
#include "nsIXULRuntime.h"
@ -1497,21 +1496,8 @@ ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
}
void
ContentParent::ShutDownProcess(ShutDownMethod aMethod)
ContentParent::ShutDownProcess(bool aCloseWithError)
{
// Shutting down by sending a shutdown message works differently than the
// other methods. We first call Shutdown() in the child. After the child is
// ready, it calls FinishShutdown() on us. Then we close the channel.
if (aMethod == SEND_SHUTDOWN_MESSAGE) {
if (mIPCOpen && SendShutdown()) {
mShutdownPending = true;
}
// If call was not successful, the channel must have been broken
// somehow, and we will clean up the error in ActorDestroy.
return;
}
using mozilla::dom::quota::QuotaManager;
if (QuotaManager* quotaManager = QuotaManager::Get()) {
@ -1519,10 +1505,10 @@ ContentParent::ShutDownProcess(ShutDownMethod aMethod)
}
// If Close() fails with an error, we'll end up back in this function, but
// with aMethod = CLOSE_CHANNEL_WITH_ERROR. It's important that we call
// with aCloseWithError = true. It's important that we call
// CloseWithError() in this case; see bug 895204.
if (aMethod == CLOSE_CHANNEL && !mCalledClose) {
if (!aCloseWithError && !mCalledClose) {
// Close() can only be called once: It kicks off the destruction
// sequence.
mCalledClose = true;
@ -1536,7 +1522,7 @@ ContentParent::ShutDownProcess(ShutDownMethod aMethod)
#endif
}
if (aMethod == CLOSE_CHANNEL_WITH_ERROR && !mCalledCloseWithError) {
if (aCloseWithError && !mCalledCloseWithError) {
MessageChannel* channel = GetIPCChannel();
if (channel) {
mCalledCloseWithError = true;
@ -1563,17 +1549,6 @@ ContentParent::ShutDownProcess(ShutDownMethod aMethod)
ShutDownMessageManager();
}
bool
ContentParent::RecvFinishShutdown()
{
// At this point, we already called ShutDownProcess once with
// SEND_SHUTDOWN_MESSAGE. To actually close the channel, we call
// ShutDownProcess again with CLOSE_CHANNEL.
MOZ_ASSERT(mShutdownPending);
ShutDownProcess(CLOSE_CHANNEL);
return true;
}
void
ContentParent::ShutDownMessageManager()
{
@ -1769,25 +1744,12 @@ struct DelayedDeleteContentParentTask : public nsRunnable
void
ContentParent::ActorDestroy(ActorDestroyReason why)
{
if (mForceKillTimer) {
mForceKillTimer->Cancel();
mForceKillTimer = nullptr;
if (mForceKillTask) {
mForceKillTask->Cancel();
mForceKillTask = nullptr;
}
// Signal shutdown completion regardless of error state,
// so we can finish waiting in the xpcom-shutdown observer.
mIPCOpen = false;
if (why == NormalShutdown && !mCalledClose) {
// If we shut down normally but haven't called Close, assume somebody
// else called Close on us. In that case, we still need to call
// ShutDownProcess below to perform other necessary clean up.
mCalledClose = true;
}
// Make sure we always clean up.
ShutDownProcess(why == NormalShutdown ? CLOSE_CHANNEL
: CLOSE_CHANNEL_WITH_ERROR);
ShutDownMessageManager();
nsRefPtr<ContentParent> kungFuDeathGrip(this);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@ -1826,6 +1788,8 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
mConsoleService = nullptr;
MarkAsDead();
if (obs) {
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
@ -1877,6 +1841,11 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
mIdleListeners.Clear();
// If the child process was terminated due to a SIGKIL, ShutDownProcess
// might not have been called yet. We must call it to ensure that our
// channel is closed, etc.
ShutDownProcess(/* closeWithError */ true);
MessageLoop::current()->
PostTask(FROM_HERE,
NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
@ -1900,7 +1869,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
CLOSE_CHANNEL));
/* closeWithError */ false));
}
cpm->RemoveContentProcess(this->ChildID());
}
@ -1923,16 +1892,14 @@ ContentParent::NotifyTabDestroying(PBrowserParent* aTab)
// recycled during its shutdown procedure.
MarkAsDead();
MOZ_ASSERT(!mForceKillTimer);
MOZ_ASSERT(!mForceKillTask);
int32_t timeoutSecs =
Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
if (timeoutSecs > 0) {
mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
MOZ_ASSERT(mForceKillTimer);
mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback,
this,
timeoutSecs * 1000,
nsITimer::TYPE_ONE_SHOT);
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
mForceKillTask = NewRunnableMethod(this, &ContentParent::KillHard),
timeoutSecs * 1000);
}
}
@ -1948,12 +1915,10 @@ ContentParent::NotifyTabDestroyed(PBrowserParent* aTab,
// because of popup windows. When the last one closes, shut
// us down.
if (ManagedPBrowserParent().Length() == 1) {
// In the case of normal shutdown, send a shutdown message to child to
// allow it to perform shutdown tasks.
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
/* force */ false));
}
}
@ -1992,6 +1957,7 @@ ContentParent::InitializeMembers()
mSubprocess = nullptr;
mChildID = gContentChildID++;
mGeolocationWatchID = -1;
mForceKillTask = nullptr;
mNumDestroyingTabs = 0;
mIsAlive = true;
mSendPermissionUpdates = false;
@ -2000,8 +1966,6 @@ ContentParent::InitializeMembers()
mCalledCloseWithError = false;
mCalledKillHard = false;
mCreatedPairedMinidumps = false;
mShutdownPending = false;
mIPCOpen = true;
}
ContentParent::ContentParent(mozIApplication* aApp,
@ -2169,8 +2133,8 @@ ContentParent::ContentParent(ContentParent* aTemplate,
ContentParent::~ContentParent()
{
if (mForceKillTimer) {
mForceKillTimer->Cancel();
if (mForceKillTask) {
mForceKillTask->Cancel();
}
if (OtherProcess())
@ -2746,16 +2710,7 @@ ContentParent::Observe(nsISupports* aSubject,
const char16_t* aData)
{
if (!strcmp(aTopic, "xpcom-shutdown") && mSubprocess) {
if (!mShutdownPending && mIPCOpen) {
ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
}
// Wait for shutdown to complete, so that we receive any shutdown
// data (e.g. telemetry) from the child before we quit.
// This loop terminate prematurely based on mForceKillTimer.
while (mIPCOpen) {
NS_ProcessNextEvent(nullptr, true);
}
ShutDownProcess(/* closeWithError */ false);
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
}
@ -3161,13 +3116,6 @@ ContentParent::DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParen
return true;
}
/* static */ void
ContentParent::ForceKillTimerCallback(nsITimer* aTimer, void* aClosure)
{
auto self = static_cast<ContentParent*>(aClosure);
self->KillHard();
}
void
ContentParent::KillHard()
{
@ -3178,7 +3126,7 @@ ContentParent::KillHard()
return;
}
mCalledKillHard = true;
mForceKillTimer = nullptr;
mForceKillTask = nullptr;
#if defined(MOZ_CRASHREPORTER) && !defined(MOZ_B2G)
if (ManagedPCrashReporterParent().Length() > 0) {

View File

@ -33,7 +33,6 @@ class nsICycleCollectorLogSink;
class nsIDOMBlob;
class nsIDumpGCAndCCLogsCallback;
class nsIMemoryReporter;
class nsITimer;
class ParentIdleListener;
namespace mozilla {
@ -335,8 +334,6 @@ public:
virtual bool RecvSetOfflinePermission(const IPC::Principal& principal) MOZ_OVERRIDE;
virtual bool RecvFinishShutdown() MOZ_OVERRIDE;
protected:
void OnChannelConnected(int32_t pid) MOZ_OVERRIDE;
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
@ -436,37 +433,23 @@ private:
*/
void MarkAsDead();
/**
* How we will shut down this ContentParent and its subprocess.
*/
enum ShutDownMethod {
// Send a shutdown message and wait for FinishShutdown call back.
SEND_SHUTDOWN_MESSAGE,
// Close the channel ourselves and let the subprocess clean up itself.
CLOSE_CHANNEL,
// Close the channel with error and let the subprocess clean up itself.
CLOSE_CHANNEL_WITH_ERROR,
};
/**
* Exit the subprocess and vamoose. After this call IsAlive()
* will return false and this ContentParent will not be returned
* by the Get*() funtions. However, the shutdown sequence itself
* may be asynchronous.
*
* If aMethod is CLOSE_CHANNEL_WITH_ERROR and this is the first call
* to ShutDownProcess, then we'll close our channel using CloseWithError()
* If aCloseWithError is true and this is the first call to
* ShutDownProcess, then we'll close our channel using CloseWithError()
* rather than vanilla Close(). CloseWithError() indicates to IPC that this
* is an abnormal shutdown (e.g. a crash).
*/
void ShutDownProcess(ShutDownMethod aMethod);
void ShutDownProcess(bool aCloseWithError);
// Perform any steps necesssary to gracefully shtudown the message
// manager and null out mMessageManager.
void ShutDownMessageManager();
static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
PCompositorParent*
AllocPCompositorParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
@ -793,7 +776,7 @@ private:
// that even content processes that are 100% blocked (say from
// SIGSTOP), are still killed eventually. This task enforces that
// timer.
nsCOMPtr<nsITimer> mForceKillTimer;
CancelableTask* mForceKillTask;
// How many tabs we're waiting to finish their destruction
// sequence. Precisely, how many TabParents have called
// NotifyTabDestroying() but not called NotifyTabDestroyed().
@ -815,8 +798,6 @@ private:
bool mCalledCloseWithError;
bool mCalledKillHard;
bool mCreatedPairedMinidumps;
bool mShutdownPending;
bool mIPCOpen;
friend class CrashReporterParent;

View File

@ -541,12 +541,6 @@ child:
prio(high) sync GetProfile()
returns (nsCString aProfile);
/**
* Notify the child to shutdown. The child will in turn call FinishShutdown
* and let the parent close the channel.
*/
async Shutdown();
NuwaFreeze();
parent:
/**
@ -883,12 +877,6 @@ parent:
*/
SetOfflinePermission(Principal principal);
/**
* Notifies the parent to continue shutting down after the child performs
* its shutdown tasks.
*/
async FinishShutdown();
both:
AsyncMessage(nsString aMessage, ClonedMessageData aData,
CpowEntry[] aCpows, Principal aPrincipal);

View File

@ -777,10 +777,7 @@ private:
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mTabChild);
// Check in case ActorDestroy was called after RecvDestroy message.
if (mTabChild->IPCOpen()) {
unused << PBrowserChild::Send__delete__(mTabChild);
}
unused << PBrowserChild::Send__delete__(mTabChild);
mTabChild = nullptr;
return NS_OK;
@ -908,7 +905,6 @@ TabChild::TabChild(nsIContentChild* aManager,
, mUniqueId(aTabId)
, mDPI(0)
, mDefaultScale(0)
, mIPCOpen(true)
{
if (!sActiveDurationMsSet) {
Preferences::AddIntVarCache(&sActiveDurationMs,
@ -1658,8 +1654,6 @@ TabChild::DestroyWindow()
void
TabChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
DestroyWindow();
if (mTabChildGlobal) {

View File

@ -499,8 +499,6 @@ public:
nsIntPoint GetChromeDisplacement() { return mChromeDisp; };
bool IPCOpen() { return mIPCOpen; }
protected:
virtual ~TabChild();
@ -664,7 +662,6 @@ private:
TabId mUniqueId;
float mDPI;
double mDefaultScale;
bool mIPCOpen;
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
};