зеркало из https://github.com/mozilla/gecko-dev.git
Bug 970307: Part 3: Reinitialize modules after fork. r=fabrice
This commit is contained in:
Родитель
f7e202983d
Коммит
d70095812d
|
@ -103,6 +103,12 @@ this.DOMApplicationRegistry = {
|
|||
this.cpmm.addMessageListener(aMsgName, this);
|
||||
}).bind(this));
|
||||
|
||||
this.resetList();
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
},
|
||||
|
||||
resetList: function() {
|
||||
this.cpmm.sendAsyncMessage("Webapps:RegisterForMessages", {
|
||||
messages: APPS_IPC_MSG_NAMES
|
||||
});
|
||||
|
@ -110,6 +116,7 @@ this.DOMApplicationRegistry = {
|
|||
// We need to prime the cache with the list of apps.
|
||||
let list = this.cpmm.sendSyncMessage("Webapps:GetList", { })[0];
|
||||
this.webapps = list.webapps;
|
||||
|
||||
// We need a fast mapping from localId -> app, so we add an index.
|
||||
// We also add the manifest to the app object.
|
||||
this.localIdIndex = { };
|
||||
|
@ -118,8 +125,6 @@ this.DOMApplicationRegistry = {
|
|||
this.localIdIndex[app.localId] = app;
|
||||
app.manifest = list.manifests[id];
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
|
|
|
@ -507,6 +507,12 @@ NS_IMPL_ISUPPORTS(BackgroundChildPrimer, nsIIPCBackgroundChildCreateCallback)
|
|||
|
||||
ContentChild* ContentChild::sSingleton;
|
||||
|
||||
static void
|
||||
PostForkPreload()
|
||||
{
|
||||
TabChild::PostForkPreload();
|
||||
}
|
||||
|
||||
// Performs initialization that is not fork-safe, i.e. that must be done after
|
||||
// forking from the Nuwa process.
|
||||
static void
|
||||
|
@ -517,6 +523,7 @@ InitOnContentProcessCreated()
|
|||
if (IsNuwaProcess()) {
|
||||
return;
|
||||
}
|
||||
PostForkPreload();
|
||||
#endif
|
||||
|
||||
// This will register cross-process observer.
|
||||
|
@ -2081,6 +2088,9 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
|
|||
#endif
|
||||
) {
|
||||
PreloadSlowThings();
|
||||
#ifndef MOZ_NUWA_PROCESS
|
||||
PostForkPreload();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
|
|
|
@ -832,6 +832,21 @@ TabChild::PreloadSlowThings()
|
|||
ClearOnShutdown(&sPreallocatedTab);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
TabChild::PostForkPreload()
|
||||
{
|
||||
// Preallocated Tab can be null if we are forked directly from b2g. In such
|
||||
// case we don't need to preload anything, just return.
|
||||
if (!sPreallocatedTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Rebuild connections to parent.
|
||||
sPreallocatedTab->RecvLoadRemoteScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/post-fork-preload.js"),
|
||||
true);
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<TabChild>
|
||||
TabChild::Create(nsIContentChild* aManager,
|
||||
const TabId& aTabId,
|
||||
|
|
|
@ -268,6 +268,7 @@ public:
|
|||
* on the critical path.
|
||||
*/
|
||||
static void PreloadSlowThings();
|
||||
static void PostForkPreload();
|
||||
|
||||
/** Return a TabChild with the given attributes. */
|
||||
static already_AddRefed<TabChild>
|
||||
|
|
|
@ -9,3 +9,4 @@ toolkit.jar:
|
|||
content/global/BrowserElementChildPreload.js (../browser-element/BrowserElementChildPreload.js)
|
||||
* content/global/BrowserElementPanning.js (../browser-element/BrowserElementPanning.js)
|
||||
content/global/preload.js (preload.js)
|
||||
content/global/post-fork-preload.js (post-fork-preload.js)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/* 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/. */
|
||||
|
||||
// Preload some things, in an attempt to make app startup faster.
|
||||
//
|
||||
// This script is run when the preallocated process starts. It is injected as
|
||||
// a frame script.
|
||||
// If Nuwa process is enabled, this script will run in preallocated process
|
||||
// forked by Nuwa.
|
||||
|
||||
(function (global) {
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/AppsServiceChild.jsm");
|
||||
Components.classes["@mozilla.org/network/protocol-proxy-service;1"].
|
||||
getService(Ci["nsIProtocolProxyService"]);
|
||||
|
||||
DOMApplicationRegistry.resetList();
|
||||
})(this);
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
// This script is run when the preallocated process starts. It is injected as
|
||||
// a frame script.
|
||||
// If nuwa is enabled, this script will run in Nuwa process before frozen.
|
||||
|
||||
const BrowserElementIsPreloaded = true;
|
||||
|
||||
|
@ -53,7 +54,6 @@ const BrowserElementIsPreloaded = true;
|
|||
Cc["@mozilla.org/network/idn-service;1"].getService(Ci["nsIIDNService"]);
|
||||
Cc["@mozilla.org/network/io-service;1"].getService(Ci["nsIIOService2"]);
|
||||
Cc["@mozilla.org/network/mime-hdrparam;1"].getService(Ci["nsIMIMEHeaderParam"]);
|
||||
Cc["@mozilla.org/network/protocol-proxy-service;1"].getService(Ci["nsIProtocolProxyService"]);
|
||||
Cc["@mozilla.org/network/socket-transport-service;1"].getService(Ci["nsISocketTransportService"]);
|
||||
Cc["@mozilla.org/network/stream-transport-service;1"].getService(Ci["nsIStreamTransportService"]);
|
||||
Cc["@mozilla.org/network/url-parser;1?auth=maybe"].getService(Ci["nsIURLParser"]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче