mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 944665: Part 1: Move common initialization routine into a function. r=khuey
This commit is contained in:
parent
5fb8a9df83
commit
bb9417d61a
@ -1249,93 +1249,13 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
||||
|
||||
Open(mSubprocess->GetChannel(), mSubprocess->GetOwnedChildProcessHandle());
|
||||
|
||||
// Set the subprocess's priority. We do this early on because we're likely
|
||||
// /lowering/ the process's CPU and memory priority, which it has inherited
|
||||
// from this process.
|
||||
//
|
||||
// This call can cause us to send IPC messages to the child process, so it
|
||||
// must come after the Open() call above.
|
||||
ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
|
||||
|
||||
// NB: internally, this will send an IPC message to the child
|
||||
// process to get it to create the CompositorChild. This
|
||||
// message goes through the regular IPC queue for this
|
||||
// channel, so delivery will happen-before any other messages
|
||||
// we send. The CompositorChild must be created before any
|
||||
// PBrowsers are created, because they rely on the Compositor
|
||||
// already being around. (Creation is async, so can't happen
|
||||
// on demand.)
|
||||
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
|
||||
if (useOffMainThreadCompositing) {
|
||||
DebugOnly<bool> opened = PCompositor::Open(this);
|
||||
MOZ_ASSERT(opened);
|
||||
|
||||
if (Preferences::GetBool("layers.async-video.enabled",false)) {
|
||||
opened = PImageBridge::Open(this);
|
||||
MOZ_ASSERT(opened);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
||||
nsChromeRegistryChrome* chromeRegistry =
|
||||
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
|
||||
chromeRegistry->SendRegisteredChrome(this);
|
||||
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
|
||||
|
||||
if (gAppData) {
|
||||
nsCString version(gAppData->version);
|
||||
nsCString buildID(gAppData->buildID);
|
||||
nsCString name(gAppData->name);
|
||||
nsCString UAName(gAppData->UAName);
|
||||
|
||||
// Sending all information to content process.
|
||||
unused << SendAppInfo(version, buildID, name, UAName);
|
||||
}
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
// This looks like a lot of work, but in a normal browser session we just
|
||||
// send two loads.
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& agentSheets = *sheetService->AgentStyleSheets();
|
||||
for (uint32_t i = 0; i < agentSheets.Length(); i++) {
|
||||
URIParams uri;
|
||||
SerializeURI(agentSheets[i]->GetSheetURI(), uri);
|
||||
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& userSheets = *sheetService->UserStyleSheets();
|
||||
for (uint32_t i = 0; i < userSheets.Length(); i++) {
|
||||
URIParams uri;
|
||||
SerializeURI(userSheets[i]->GetSheetURI(), uri);
|
||||
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& authorSheets = *sheetService->AuthorStyleSheets();
|
||||
for (uint32_t i = 0; i < authorSheets.Length(); i++) {
|
||||
URIParams uri;
|
||||
SerializeURI(authorSheets[i]->GetSheetURI(), uri);
|
||||
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_CONTENT_SANDBOX
|
||||
// Bug 921817. We enable the sandbox in RecvSetProcessPrivileges,
|
||||
// which is where a preallocated process drops unnecessary privileges,
|
||||
// but a non-preallocated process will already have changed its
|
||||
// uid/gid/etc immediately after forking. Thus, we send this message,
|
||||
// which is otherwise a no-op, to sandbox it at an appropriate point
|
||||
// during startup.
|
||||
if (aOSPrivileges != base::PRIVILEGES_INHERIT) {
|
||||
if (!SendSetProcessPrivileges(base::PRIVILEGES_INHERIT)) {
|
||||
KillHard();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
InitInternal(aInitialPriority,
|
||||
true, /* Setup off-main thread compositing */
|
||||
true /* Send registered chrome */);
|
||||
}
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
static const FileDescriptor*
|
||||
static const mozilla::ipc::FileDescriptor*
|
||||
FindFdProtocolFdMapping(const nsTArray<ProtocolFdMapping>& aFds,
|
||||
ProtocolId aProtoId)
|
||||
{
|
||||
@ -1401,8 +1321,9 @@ ContentParent::ContentParent(ContentParent* aTemplate,
|
||||
priority = PROCESS_PRIORITY_FOREGROUND;
|
||||
}
|
||||
|
||||
ProcessPriorityManager::SetProcessPriority(this, priority);
|
||||
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
|
||||
InitInternal(priority,
|
||||
false, /* Setup Off-main thread compositing */
|
||||
false /* Send registered chrome */);
|
||||
}
|
||||
#endif // MOZ_NUWA_PROCESS
|
||||
|
||||
@ -1432,6 +1353,101 @@ ContentParent::~ContentParent()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
bool aSetupOffMainThreadCompositing,
|
||||
bool aSendRegisteredChrome)
|
||||
{
|
||||
// Set the subprocess's priority. We do this early on because we're likely
|
||||
// /lowering/ the process's CPU and memory priority, which it has inherited
|
||||
// from this process.
|
||||
//
|
||||
// This call can cause us to send IPC messages to the child process, so it
|
||||
// must come after the Open() call above.
|
||||
ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
|
||||
|
||||
if (aSetupOffMainThreadCompositing) {
|
||||
// NB: internally, this will send an IPC message to the child
|
||||
// process to get it to create the CompositorChild. This
|
||||
// message goes through the regular IPC queue for this
|
||||
// channel, so delivery will happen-before any other messages
|
||||
// we send. The CompositorChild must be created before any
|
||||
// PBrowsers are created, because they rely on the Compositor
|
||||
// already being around. (Creation is async, so can't happen
|
||||
// on demand.)
|
||||
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
|
||||
if (useOffMainThreadCompositing) {
|
||||
DebugOnly<bool> opened = PCompositor::Open(this);
|
||||
MOZ_ASSERT(opened);
|
||||
|
||||
if (Preferences::GetBool("layers.async-video.enabled",false)) {
|
||||
opened = PImageBridge::Open(this);
|
||||
MOZ_ASSERT(opened);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aSendRegisteredChrome) {
|
||||
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
||||
nsChromeRegistryChrome* chromeRegistry =
|
||||
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
|
||||
chromeRegistry->SendRegisteredChrome(this);
|
||||
}
|
||||
|
||||
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
|
||||
|
||||
if (gAppData) {
|
||||
nsCString version(gAppData->version);
|
||||
nsCString buildID(gAppData->buildID);
|
||||
nsCString name(gAppData->name);
|
||||
nsCString UAName(gAppData->UAName);
|
||||
|
||||
// Sending all information to content process.
|
||||
unused << SendAppInfo(version, buildID, name, UAName);
|
||||
}
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
// This looks like a lot of work, but in a normal browser session we just
|
||||
// send two loads.
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& agentSheets = *sheetService->AgentStyleSheets();
|
||||
for (uint32_t i = 0; i < agentSheets.Length(); i++) {
|
||||
URIParams uri;
|
||||
SerializeURI(agentSheets[i]->GetSheetURI(), uri);
|
||||
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& userSheets = *sheetService->UserStyleSheets();
|
||||
for (uint32_t i = 0; i < userSheets.Length(); i++) {
|
||||
URIParams uri;
|
||||
SerializeURI(userSheets[i]->GetSheetURI(), uri);
|
||||
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& authorSheets = *sheetService->AuthorStyleSheets();
|
||||
for (uint32_t i = 0; i < authorSheets.Length(); i++) {
|
||||
URIParams uri;
|
||||
SerializeURI(authorSheets[i]->GetSheetURI(), uri);
|
||||
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_CONTENT_SANDBOX
|
||||
// Bug 921817. We enable the sandbox in RecvSetProcessPrivileges,
|
||||
// which is where a preallocated process drops unnecessary privileges,
|
||||
// but a non-preallocated process will already have changed its
|
||||
// uid/gid/etc immediately after forking. Thus, we send this message,
|
||||
// which is otherwise a no-op, to sandbox it at an appropriate point
|
||||
// during startup.
|
||||
if (mOSPrivileges != base::PRIVILEGES_INHERIT) {
|
||||
if (!SendSetProcessPrivileges(base::PRIVILEGES_INHERIT)) {
|
||||
KillHard();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::IsAlive()
|
||||
{
|
||||
|
@ -265,6 +265,11 @@ private:
|
||||
// The common initialization for the constructors.
|
||||
void InitializeMembers();
|
||||
|
||||
// The common initialization logic shared by all constuctors.
|
||||
void InitInternal(ProcessPriority aPriority,
|
||||
bool aSetupOffMainThreadCompositing,
|
||||
bool aSendRegisteredChrome);
|
||||
|
||||
virtual ~ContentParent();
|
||||
|
||||
void Init();
|
||||
|
Loading…
Reference in New Issue
Block a user