Bug 1112989 - Part 1. Forward know info to ContentChild before app startup. r=fabrice

This commit is contained in:
Kan-Ru Chen (陳侃如) 2015-01-28 13:52:46 +08:00
Родитель e60bb87514
Коммит de539ad7ed
2 изменённых файлов: 29 добавлений и 0 удалений

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

@ -672,6 +672,8 @@ ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
}
process->TransformPreallocatedIntoApp(aOpener,
manifestURL);
process->ForwardKnownInfo();
if (aTookPreAllocated) {
*aTookPreAllocated = true;
}
@ -688,6 +690,7 @@ ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
/* isForPreallocated = */ false,
aInitialPriority);
process->Init();
process->ForwardKnownInfo();
if (aTookPreAllocated) {
*aTookPreAllocated = false;
@ -831,6 +834,7 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
aPriority);
p->Init();
}
p->ForwardKnownInfo();
sNonAppContentParents->AppendElement(p);
return p.forget();
@ -1308,6 +1312,15 @@ ContentParent::Init()
NS_ASSERTION(observer, "FileUpdateDispatcher is null");
}
void
ContentParent::ForwardKnownInfo()
{
MOZ_ASSERT(mMetamorphosed);
if (!mMetamorphosed) {
return;
}
}
namespace {
class SystemMessageHandledListener MOZ_FINAL
@ -1497,6 +1510,7 @@ ContentParent::TransformPreallocatedIntoApp(ContentParent* aOpener,
const nsAString& aAppManifestURL)
{
MOZ_ASSERT(IsPreallocated());
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL = aAppManifestURL;
TryGetNameFromManifestURL(aAppManifestURL, mAppName);
@ -1506,6 +1520,7 @@ void
ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
{
// Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL.Truncate();
mIsForBrowser = true;
@ -2032,6 +2047,7 @@ ContentParent::InitializeMembers()
mGeolocationWatchID = -1;
mNumDestroyingTabs = 0;
mIsAlive = true;
mMetamorphosed = false;
mSendPermissionUpdates = false;
mSendDataStoreInfos = false;
mCalledClose = false;
@ -2063,6 +2079,10 @@ ContentParent::ContentParent(mozIApplication* aApp,
// Only the preallocated process uses Nuwa.
MOZ_ASSERT_IF(aIsNuwaProcess, aIsForPreallocated);
if (!aIsNuwaProcess && !aIsForPreallocated) {
mMetamorphosed = true;
}
// Insert ourselves into the global linked list of ContentParent objects.
if (!sContentParents) {
sContentParents = new LinkedList<ContentParent>();

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

@ -410,6 +410,11 @@ private:
void Init();
// Some information could be sent to content very early, it
// should be send from this function. This function should only be
// called after the process has been transformed to app or browser.
void ForwardKnownInfo();
// If the frame element indicates that the child process is "critical" and
// has a pending system message, this function acquires the CPU wake lock on
// behalf of the child. We'll release the lock when the system message is
@ -812,6 +817,10 @@ private:
// through.
bool mIsAlive;
// True only the if process is already a browser or app or has
// been transformed into one.
bool mMetamorphosed;
bool mSendPermissionUpdates;
bool mSendDataStoreInfos;
bool mIsForBrowser;