2013-04-26 04:53:26 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et ft=cpp : */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/PreallocatedProcessManager.h"
|
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2014-08-15 05:47:15 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIPropertyBag2.h"
|
2013-11-22 07:25:34 +04:00
|
|
|
#include "ProcessPriorityManager.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
#include "ipc/Nuwa.h"
|
|
|
|
#endif
|
|
|
|
|
2014-11-01 08:28:33 +03:00
|
|
|
#ifdef MOZ_B2G_LOADER
|
|
|
|
#include "ProcessUtils.h"
|
|
|
|
#endif
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
// This number is fairly arbitrary ... the intention is to put off
|
|
|
|
// launching another app process until the last one has finished
|
|
|
|
// loading its content, to reduce CPU/memory/IO contention.
|
|
|
|
#define DEFAULT_ALLOCATE_DELAY 1000
|
|
|
|
#define NUWA_FORK_WAIT_DURATION_MS 2000 // 2 seconds.
|
2013-04-26 04:53:26 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::hal;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This singleton class implements the static methods on
|
|
|
|
* PreallocatedProcessManager.
|
|
|
|
*/
|
|
|
|
class PreallocatedProcessManagerImpl MOZ_FINAL
|
|
|
|
: public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static PreallocatedProcessManagerImpl* Singleton();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
// See comments on PreallocatedProcessManager for these methods.
|
|
|
|
void AllocateAfterDelay();
|
|
|
|
void AllocateOnIdle();
|
|
|
|
void AllocateNow();
|
|
|
|
already_AddRefed<ContentParent> Take();
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
public:
|
|
|
|
void ScheduleDelayedNuwaFork();
|
|
|
|
void DelayedNuwaFork();
|
|
|
|
void PublishSpareProcess(ContentParent* aContent);
|
|
|
|
void MaybeForgetSpare(ContentParent* aContent);
|
2014-05-09 15:30:42 +04:00
|
|
|
bool IsNuwaReady();
|
2013-11-22 07:25:34 +04:00
|
|
|
void OnNuwaReady();
|
2013-11-19 15:03:30 +04:00
|
|
|
bool PreallocatedProcessReady();
|
2013-11-22 07:25:34 +04:00
|
|
|
already_AddRefed<ContentParent> GetSpareProcess();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void NuwaFork();
|
|
|
|
|
|
|
|
// initialization off the critical path of app startup.
|
|
|
|
CancelableTask* mPreallocateAppProcessTask;
|
|
|
|
|
|
|
|
// The array containing the preallocated processes. 4 as the inline storage size
|
|
|
|
// should be enough so we don't need to grow the nsAutoTArray.
|
|
|
|
nsAutoTArray<nsRefPtr<ContentParent>, 4> mSpareProcesses;
|
|
|
|
|
|
|
|
// Nuwa process is ready for creating new process.
|
|
|
|
bool mIsNuwaReady;
|
|
|
|
#endif
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
private:
|
|
|
|
static mozilla::StaticRefPtr<PreallocatedProcessManagerImpl> sSingleton;
|
|
|
|
|
|
|
|
PreallocatedProcessManagerImpl();
|
2014-06-23 23:56:07 +04:00
|
|
|
~PreallocatedProcessManagerImpl() {}
|
2013-04-26 04:53:26 +04:00
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(PreallocatedProcessManagerImpl);
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
void RereadPrefs();
|
|
|
|
void Enable();
|
|
|
|
void Disable();
|
|
|
|
|
|
|
|
void ObserveProcessShutdown(nsISupports* aSubject);
|
|
|
|
|
|
|
|
bool mEnabled;
|
2013-12-09 18:42:48 +04:00
|
|
|
bool mShutdown;
|
2013-04-26 04:53:26 +04:00
|
|
|
nsRefPtr<ContentParent> mPreallocatedAppProcess;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* static */ StaticRefPtr<PreallocatedProcessManagerImpl>
|
|
|
|
PreallocatedProcessManagerImpl::sSingleton;
|
|
|
|
|
|
|
|
/* static */ PreallocatedProcessManagerImpl*
|
|
|
|
PreallocatedProcessManagerImpl::Singleton()
|
|
|
|
{
|
|
|
|
if (!sSingleton) {
|
|
|
|
sSingleton = new PreallocatedProcessManagerImpl();
|
|
|
|
sSingleton->Init();
|
|
|
|
ClearOnShutdown(&sSingleton);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sSingleton;
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(PreallocatedProcessManagerImpl, nsIObserver)
|
2013-04-26 04:53:26 +04:00
|
|
|
|
|
|
|
PreallocatedProcessManagerImpl::PreallocatedProcessManagerImpl()
|
|
|
|
: mEnabled(false)
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
, mPreallocateAppProcessTask(nullptr)
|
|
|
|
, mIsNuwaReady(false)
|
|
|
|
#endif
|
2013-12-09 18:42:48 +04:00
|
|
|
, mShutdown(false)
|
2013-04-26 04:53:26 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::Init()
|
|
|
|
{
|
|
|
|
Preferences::AddStrongObserver(this, "dom.ipc.processPrelaunch.enabled");
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
os->AddObserver(this, "ipc:content-shutdown",
|
|
|
|
/* weakRef = */ false);
|
2013-12-09 18:42:48 +04:00
|
|
|
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
|
|
|
/* weakRef = */ false);
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
2014-11-01 08:28:33 +03:00
|
|
|
#ifdef MOZ_B2G_LOADER
|
|
|
|
if (!mozilla::ipc::ProcLoaderIsInitialized()) {
|
|
|
|
Disable();
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
RereadPrefs();
|
|
|
|
}
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aData)
|
2013-04-26 04:53:26 +04:00
|
|
|
{
|
|
|
|
if (!strcmp("ipc:content-shutdown", aTopic)) {
|
|
|
|
ObserveProcessShutdown(aSubject);
|
|
|
|
} else if (!strcmp("nsPref:changed", aTopic)) {
|
|
|
|
// The only other observer we registered was for our prefs.
|
|
|
|
RereadPrefs();
|
2013-12-09 18:42:48 +04:00
|
|
|
} else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
|
|
|
|
mShutdown = true;
|
2013-04-26 04:53:26 +04:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::RereadPrefs()
|
|
|
|
{
|
|
|
|
if (Preferences::GetBool("dom.ipc.processPrelaunch.enabled")) {
|
|
|
|
Enable();
|
|
|
|
} else {
|
|
|
|
Disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<ContentParent>
|
|
|
|
PreallocatedProcessManagerImpl::Take()
|
|
|
|
{
|
|
|
|
return mPreallocatedAppProcess.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::Enable()
|
|
|
|
{
|
|
|
|
if (mEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mEnabled = true;
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
ScheduleDelayedNuwaFork();
|
|
|
|
#else
|
2013-04-26 04:53:26 +04:00
|
|
|
AllocateAfterDelay();
|
2013-11-22 07:25:34 +04:00
|
|
|
#endif
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::AllocateAfterDelay()
|
|
|
|
{
|
|
|
|
if (!mEnabled || mPreallocatedAppProcess) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageLoop::current()->PostDelayedTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle),
|
2013-11-22 07:25:34 +04:00
|
|
|
Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
|
|
|
|
DEFAULT_ALLOCATE_DELAY));
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::AllocateOnIdle()
|
|
|
|
{
|
|
|
|
if (!mEnabled || mPreallocatedAppProcess) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageLoop::current()->PostIdleTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::AllocateNow()
|
|
|
|
{
|
|
|
|
if (!mEnabled || mPreallocatedAppProcess) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPreallocatedAppProcess = ContentParent::PreallocateAppProcess();
|
|
|
|
}
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::ScheduleDelayedNuwaFork()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mPreallocateAppProcessTask) {
|
|
|
|
// Make sure there is only one request running.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPreallocateAppProcessTask = NewRunnableMethod(
|
|
|
|
this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
|
|
|
|
MessageLoop::current()->PostDelayedTask(
|
|
|
|
FROM_HERE, mPreallocateAppProcessTask,
|
|
|
|
Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
|
|
|
|
DEFAULT_ALLOCATE_DELAY));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::DelayedNuwaFork()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
mPreallocateAppProcessTask = nullptr;
|
|
|
|
|
|
|
|
if (!mIsNuwaReady) {
|
2013-12-13 12:38:08 +04:00
|
|
|
if (!mPreallocatedAppProcess && !mShutdown && mEnabled) {
|
2013-11-22 07:25:34 +04:00
|
|
|
mPreallocatedAppProcess = ContentParent::RunNuwaProcess();
|
|
|
|
}
|
|
|
|
// else mPreallocatedAppProcess is starting. It will NuwaFork() when ready.
|
|
|
|
} else if (mSpareProcesses.IsEmpty()) {
|
|
|
|
NuwaFork();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a spare ContentParent from mSpareProcesses list.
|
|
|
|
*/
|
|
|
|
already_AddRefed<ContentParent>
|
|
|
|
PreallocatedProcessManagerImpl::GetSpareProcess()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mSpareProcesses.IsEmpty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<ContentParent> process = mSpareProcesses.LastElement();
|
|
|
|
mSpareProcesses.RemoveElementAt(mSpareProcesses.Length() - 1);
|
|
|
|
|
|
|
|
if (mSpareProcesses.IsEmpty() && mIsNuwaReady) {
|
|
|
|
NS_ASSERTION(mPreallocatedAppProcess != nullptr,
|
|
|
|
"Nuwa process is not present!");
|
|
|
|
ScheduleDelayedNuwaFork();
|
|
|
|
}
|
|
|
|
|
|
|
|
return process.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Publish a ContentParent to spare process list.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::PublishSpareProcess(ContentParent* aContent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2013-10-24 17:49:49 +04:00
|
|
|
if (Preferences::GetBool("dom.ipc.processPriorityManager.testMode")) {
|
|
|
|
AutoJSContext cx;
|
|
|
|
nsCOMPtr<nsIMessageBroadcaster> ppmm =
|
|
|
|
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
|
|
|
|
nsresult rv = ppmm->BroadcastAsyncMessage(
|
|
|
|
NS_LITERAL_STRING("TEST-ONLY:nuwa-add-new-process"),
|
2014-01-15 04:00:25 +04:00
|
|
|
JS::NullHandleValue, JS::NullHandleValue, cx, 1);
|
2013-10-24 17:49:49 +04:00
|
|
|
}
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
mSpareProcesses.AppendElement(aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::MaybeForgetSpare(ContentParent* aContent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mSpareProcesses.RemoveElement(aContent)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aContent == mPreallocatedAppProcess) {
|
|
|
|
mPreallocatedAppProcess = nullptr;
|
|
|
|
mIsNuwaReady = false;
|
2014-05-15 07:04:32 +04:00
|
|
|
while (mSpareProcesses.Length() > 0) {
|
|
|
|
nsRefPtr<ContentParent> process = mSpareProcesses[mSpareProcesses.Length() - 1];
|
|
|
|
process->Close();
|
|
|
|
mSpareProcesses.RemoveElementAt(mSpareProcesses.Length() - 1);
|
|
|
|
}
|
2013-11-22 07:25:34 +04:00
|
|
|
ScheduleDelayedNuwaFork();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-09 15:30:42 +04:00
|
|
|
bool
|
|
|
|
PreallocatedProcessManagerImpl::IsNuwaReady()
|
|
|
|
{
|
|
|
|
return mIsNuwaReady;
|
|
|
|
}
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::OnNuwaReady()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mIsNuwaReady, "Multiple Nuwa processes created!");
|
|
|
|
ProcessPriorityManager::SetProcessPriority(mPreallocatedAppProcess,
|
2013-12-22 13:21:02 +04:00
|
|
|
hal::PROCESS_PRIORITY_MASTER);
|
2013-11-22 07:25:34 +04:00
|
|
|
mIsNuwaReady = true;
|
2013-10-24 17:49:49 +04:00
|
|
|
if (Preferences::GetBool("dom.ipc.processPriorityManager.testMode")) {
|
|
|
|
AutoJSContext cx;
|
|
|
|
nsCOMPtr<nsIMessageBroadcaster> ppmm =
|
|
|
|
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
|
|
|
|
nsresult rv = ppmm->BroadcastAsyncMessage(
|
|
|
|
NS_LITERAL_STRING("TEST-ONLY:nuwa-ready"),
|
2014-01-15 04:00:25 +04:00
|
|
|
JS::NullHandleValue, JS::NullHandleValue, cx, 1);
|
2013-10-24 17:49:49 +04:00
|
|
|
}
|
2013-11-22 07:25:34 +04:00
|
|
|
NuwaFork();
|
|
|
|
}
|
|
|
|
|
2013-11-19 15:03:30 +04:00
|
|
|
bool
|
|
|
|
PreallocatedProcessManagerImpl::PreallocatedProcessReady()
|
|
|
|
{
|
|
|
|
return !mSpareProcesses.IsEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::NuwaFork()
|
|
|
|
{
|
|
|
|
mPreallocatedAppProcess->SendNuwaFork();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::Disable()
|
|
|
|
{
|
|
|
|
if (!mEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mEnabled = false;
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Cancel pending fork.
|
|
|
|
if (mPreallocateAppProcessTask) {
|
|
|
|
mPreallocateAppProcessTask->Cancel();
|
|
|
|
mPreallocateAppProcessTask = nullptr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
if (mPreallocatedAppProcess) {
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
while (mSpareProcesses.Length() > 0){
|
|
|
|
nsRefPtr<ContentParent> process = mSpareProcesses[0];
|
|
|
|
process->Close();
|
|
|
|
mSpareProcesses.RemoveElementAt(0);
|
|
|
|
}
|
|
|
|
mIsNuwaReady = false;
|
|
|
|
#endif
|
|
|
|
mPreallocatedAppProcess->Close();
|
2013-04-26 04:53:26 +04:00
|
|
|
mPreallocatedAppProcess = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PreallocatedProcessManagerImpl::ObserveProcessShutdown(nsISupports* aSubject)
|
|
|
|
{
|
|
|
|
if (!mPreallocatedAppProcess) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
|
|
|
|
NS_ENSURE_TRUE_VOID(props);
|
|
|
|
|
|
|
|
uint64_t childID = CONTENT_PROCESS_ID_UNKNOWN;
|
|
|
|
props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"), &childID);
|
|
|
|
NS_ENSURE_TRUE_VOID(childID != CONTENT_PROCESS_ID_UNKNOWN);
|
|
|
|
|
|
|
|
if (childID == mPreallocatedAppProcess->ChildID()) {
|
|
|
|
mPreallocatedAppProcess = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
inline PreallocatedProcessManagerImpl* GetPPMImpl()
|
|
|
|
{
|
|
|
|
return PreallocatedProcessManagerImpl::Singleton();
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
PreallocatedProcessManager::AllocateAfterDelay()
|
|
|
|
{
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
GetPPMImpl()->ScheduleDelayedNuwaFork();
|
|
|
|
#else
|
|
|
|
GetPPMImpl()->AllocateAfterDelay();
|
|
|
|
#endif
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
PreallocatedProcessManager::AllocateOnIdle()
|
|
|
|
{
|
2013-11-22 07:25:34 +04:00
|
|
|
GetPPMImpl()->AllocateOnIdle();
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
PreallocatedProcessManager::AllocateNow()
|
|
|
|
{
|
2013-11-22 07:25:34 +04:00
|
|
|
GetPPMImpl()->AllocateNow();
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ already_AddRefed<ContentParent>
|
|
|
|
PreallocatedProcessManager::Take()
|
|
|
|
{
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
return GetPPMImpl()->GetSpareProcess();
|
|
|
|
#else
|
|
|
|
return GetPPMImpl()->Take();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
/* static */ void
|
|
|
|
PreallocatedProcessManager::PublishSpareProcess(ContentParent* aContent)
|
|
|
|
{
|
|
|
|
GetPPMImpl()->PublishSpareProcess(aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
PreallocatedProcessManager::MaybeForgetSpare(ContentParent* aContent)
|
|
|
|
{
|
|
|
|
GetPPMImpl()->MaybeForgetSpare(aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
PreallocatedProcessManager::OnNuwaReady()
|
|
|
|
{
|
|
|
|
GetPPMImpl()->OnNuwaReady();
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
2013-11-19 15:03:30 +04:00
|
|
|
|
2014-05-09 15:30:42 +04:00
|
|
|
/* static */ bool
|
|
|
|
PreallocatedProcessManager::IsNuwaReady()
|
|
|
|
{
|
|
|
|
return GetPPMImpl()->IsNuwaReady();
|
|
|
|
}
|
|
|
|
|
2013-11-19 15:03:30 +04:00
|
|
|
/*static */ bool
|
|
|
|
PreallocatedProcessManager::PreallocatedProcessReady()
|
|
|
|
{
|
|
|
|
return GetPPMImpl()->PreallocatedProcessReady();
|
|
|
|
}
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
#endif
|
2013-04-26 04:53:26 +04:00
|
|
|
|
|
|
|
} // namespace mozilla
|