diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index bcf43ffd0768..709b443da71e 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -507,7 +507,7 @@ pref("dom.ipc.processPriorityManager.enabled", true); pref("dom.ipc.processPriorityManager.gracePeriodMS", 1000); pref("hal.processPriorityManager.gonk.masterOomAdjust", 0); pref("hal.processPriorityManager.gonk.foregroundOomAdjust", 1); -pref("hal.processPriorityManager.gonk.backgroundOomAdjust", 2); +pref("hal.processPriorityManager.gonk.backgroundOomAdjust", 6); pref("hal.processPriorityManager.gonk.masterNice", -1); pref("hal.processPriorityManager.gonk.foregroundNice", 0); pref("hal.processPriorityManager.gonk.backgroundNice", 10); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index edfa2e4a721f..58bf98680506 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -19,9 +19,11 @@ #include "AudioChild.h" #endif +#include "mozilla/Attributes.h" #include "mozilla/dom/ExternalHelperAppChild.h" #include "mozilla/dom/PCrashReporterChild.h" #include "mozilla/dom/StorageChild.h" +#include "mozilla/Hal.h" #include "mozilla/hal_sandbox/PHalChild.h" #include "mozilla/ipc/TestShellChild.h" #include "mozilla/ipc/XPCShellEnvironment.h" @@ -31,7 +33,6 @@ #include "mozilla/layers/PCompositorChild.h" #include "mozilla/net/NeckoChild.h" #include "mozilla/Preferences.h" -#include "mozilla/Attributes.h" #if defined(MOZ_SYDNEYAUDIO) #include "nsAudioStream.h" @@ -100,6 +101,7 @@ #include "nsContentUtils.h" #include "nsIPrincipal.h" +using namespace base; using namespace mozilla::docshell; using namespace mozilla::dom::devicestorage; using namespace mozilla::dom::sms; @@ -287,6 +289,14 @@ ContentChild::Init(MessageLoop* aIOLoop, #endif #endif + bool startBackground = true; + SendGetProcessAttributes(&mID, &startBackground, + &mIsForApp, &mIsForBrowser); + hal::SetProcessPriority( + GetCurrentProcId(), + startBackground ? hal::PROCESS_PRIORITY_BACKGROUND: + hal::PROCESS_PRIORITY_FOREGROUND); + return true; } @@ -951,20 +961,6 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID) return true; } -bool -ContentChild::RecvSetProcessAttributes(const uint64_t &id, - const bool& aIsForApp, - const bool& aIsForBrowser) -{ - if (mID != uint64_t(-1)) { - NS_WARNING("Setting content child's ID twice?"); - } - mID = id; - mIsForApp = aIsForApp; - mIsForBrowser = aIsForBrowser; - return true; -} - bool ContentChild::RecvLastPrivateDocShellDestroyed() { diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index bb441ea12a2c..846a9e3acb00 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -167,9 +167,6 @@ public: virtual bool RecvCycleCollect(); virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID); - virtual bool RecvSetProcessAttributes(const uint64_t& id, - const bool& aIsForApp, - const bool& aIsForBrowser); virtual bool RecvLastPrivateDocShellDestroyed(); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 186ace60dc1c..fc2ff8f940fc 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -686,9 +686,10 @@ ContentParent::ContentParent(const nsAString& aAppManifestURL, , mGeolocationWatchID(-1) , mRunToCompletionDepth(0) , mShouldCallUnblockChild(false) + , mAppManifestURL(aAppManifestURL) , mIsAlive(true) , mSendPermissionUpdates(false) - , mAppManifestURL(aAppManifestURL) + , mIsForBrowser(aIsForBrowser) { // From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the // PID along with the warning. @@ -707,8 +708,6 @@ ContentParent::ContentParent(const nsAString& aAppManifestURL, mSubprocess->AsyncLaunch(); } Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle()); - unused << SendSetProcessAttributes(gContentChildID++, - IsForApp(), aIsForBrowser); // NB: internally, this will send an IPC message to the child // process to get it to create the CompositorChild. This @@ -1087,6 +1086,18 @@ ContentParent::AllocPImageBridge(mozilla::ipc::Transport* aTransport, return ImageBridgeParent::Create(aTransport, aOtherProcess); } +bool +ContentParent::RecvGetProcessAttributes(uint64_t* aId, bool* aStartBackground, + bool* aIsForApp, bool* aIsForBrowser) +{ + *aId = gContentChildID++; + *aStartBackground = + (mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL); + *aIsForApp = IsForApp(); + *aIsForBrowser = mIsForBrowser; + return true; +} + PBrowserParent* ContentParent::AllocPBrowser(const uint32_t& aChromeFlags, const bool& aIsBrowserElement, const AppId& aApp) diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 56625c17c637..223982137bc5 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -164,6 +164,11 @@ private: AllocPImageBridge(mozilla::ipc::Transport* aTransport, base::ProcessId aOtherProcess) MOZ_OVERRIDE; + virtual bool RecvGetProcessAttributes(uint64_t* aId, + bool* aStartBackground, + bool* aIsForApp, + bool* aIsForBrowser) MOZ_OVERRIDE; + virtual PBrowserParent* AllocPBrowser(const uint32_t& aChromeFlags, const bool& aIsBrowserElement, const AppId& aApp); @@ -297,12 +302,13 @@ private: // the nsIObserverService. nsCOMArray mMemoryReporters; - bool mIsAlive; - bool mSendPermissionUpdates; - const nsString mAppManifestURL; nsRefPtr mMessageManager; + bool mIsAlive; + bool mSendPermissionUpdates; + bool mIsForBrowser; + friend class CrashReporterParent; }; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 887ab0141259..6e5a0e79af91 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -198,17 +198,6 @@ child: PTestShell(); - /** - * Tell the content process some attributes of itself. This is - * the first message received by content processes after startup. - * - * |id| is a unique ID among all subprocesses. When |isForApp && - * isForBrowser|, we're loading for an app. When - * |isForBrowser|, we're loading . When |!isForApp && - * !isForBrowser|, we're probably loading . - */ - SetProcessAttributes(uint64_t id, bool isForApp, bool isForBrowser); - RegisterChrome(ChromePackage[] packages, ResourceMapping[] resources, OverrideMapping[] overrides, nsCString locale); @@ -247,6 +236,21 @@ child: FileSystemUpdate(nsString fsName, nsString mountPoint, int32_t fsState); parent: + /** + * Tell the content process some attributes of itself. This is + * among the first information queried by content processes after + * startup. (The message is sync to allow the content process to + * control when it receives the information.) + * + * |id| is a unique ID among all subprocesses. When |isForApp && + * isForBrowser|, we're loading for an app. When + * |isForBrowser|, we're loading . When |!isForApp && + * !isForBrowser|, we're probably loading . + */ + sync GetProcessAttributes() + returns (uint64_t id, bool startBackground, + bool isForApp, bool isForBrowser); + PAudio(int32_t aNumChannels, int32_t aRate, int32_t aFormat); PDeviceStorageRequest(DeviceStorageParams params);