Bug 890870 - Start freezing the Nuwa process after PreloadSlowThings(). r=khuey

This commit is contained in:
Cervantes Yu 2013-10-01 19:28:44 +08:00
parent bcd25ca726
commit 82360aea08
2 changed files with 20 additions and 35 deletions

View File

@ -1290,6 +1290,14 @@ ContentChild::RecvCycleCollect()
return true;
}
#ifdef MOZ_NUWA_PROCESS
static void
OnFinishNuwaPreparation ()
{
MakeNuwaProcess();
}
#endif
static void
PreloadSlowThings()
{
@ -1297,6 +1305,18 @@ PreloadSlowThings()
nsLayoutStylesheetCache::UserContentSheet();
TabChild::PreloadSlowThings();
#ifdef MOZ_NUWA_PROCESS
// After preload of slow things, start freezing threads.
if (IsNuwaProcess()) {
// Perform GC before freezing the Nuwa process to reduce memory usage.
ContentChild::GetSingleton()->RecvGarbageCollect();
MessageLoop::current()->
PostTask(FROM_HERE,
NewRunnableFunction(OnFinishNuwaPreparation));
}
#endif
}
bool

View File

@ -77,11 +77,6 @@
using mozilla::_ipdltest::IPDLUnitTestProcessChild;
#endif // ifdef MOZ_IPDL_TESTS
#ifdef MOZ_NUWA_PROCESS
#include "nsITimer.h"
#define NUWA_PREPARATION_TIME 1000
#endif
using namespace mozilla;
using mozilla::ipc::BrowserProcessSubThread;
@ -107,13 +102,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
static const PRUnichar kShellLibraryName[] = L"shell32.dll";
#endif
#ifdef MOZ_NUWA_PROCESS
extern "C" {
void PrepareNuwaProcess() __attribute__((weak));
void MakeNuwaProcess() __attribute__((weak));
};
#endif
nsresult
XRE_LockProfileDirectory(nsIFile* aDirectory,
nsISupports* *aLockObject)
@ -277,16 +265,6 @@ SetTaskbarGroupId(const nsString& aId)
}
#endif
#ifdef MOZ_NUWA_PROCESS
void
OnFinishNuwaPreparation(nsITimer *aTimer, void *aClosure)
{
NS_ASSERTION(MakeNuwaProcess != nullptr,
"MakeNuwaProcess() is not available!");
MakeNuwaProcess();
}
#endif
nsresult
XRE_InitChildProcess(int aArgc,
char* aArgv[],
@ -534,19 +512,6 @@ XRE_InitChildProcess(int aArgc,
return NS_ERROR_FAILURE;
}
#ifdef MOZ_NUWA_PROCESS
nsCOMPtr<nsITimer> timer;
if (aProcess == GeckoProcessType_Content &&
CommandLine::ForCurrentProcess()->HasSwitch(L"nuwa")) {
// Wait the Nuwa process for NUWA_PREPARATION_TIME ms.
timer = do_CreateInstance(NS_TIMER_CONTRACTID);
rv = timer->InitWithFuncCallback(OnFinishNuwaPreparation,
nullptr,
NUWA_PREPARATION_TIME,
nsITimer::TYPE_ONE_SHOT);
}
#endif
// Run the UI event loop on the main thread.
uiMessageLoop.MessageLoop::Run();