summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 22:06:41 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 22:06:41 +0000
commitf30a566d7fcc4c56004f40e9db160906bdf9ac8c (patch)
treec0d6b4c308cf7853205717a63b27ea8ce276a93b
parent6e5e54e39d8e542077acdafe8cf9033b1ca9acce (diff)
downloadchromium_src-f30a566d7fcc4c56004f40e9db160906bdf9ac8c.zip
chromium_src-f30a566d7fcc4c56004f40e9db160906bdf9ac8c.tar.gz
chromium_src-f30a566d7fcc4c56004f40e9db160906bdf9ac8c.tar.bz2
Add an "extension" process type, which mostly gets treated as a renderer everywhere.
BUG=27163 Review URL: http://codereview.chromium.org/384108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31955 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chrome_dll_main.cc7
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc18
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h5
-rw-r--r--chrome/browser/sandbox_policy.cc3
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/sandbox_init_wrapper_mac.cc3
-rw-r--r--chrome/common/sandbox_init_wrapper_win.cc1
8 files changed, 37 insertions, 4 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index e16df52..8d62ddb 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -545,7 +545,8 @@ int ChromeMain(int argc, char** argv) {
#if defined (OS_MACOSX)
// On OS X the renderer sandbox needs to be initialized later in the startup
// sequence in RendererMainPlatformDelegate::PlatformInitialize().
- if (process_type != switches::kRendererProcess)
+ if (process_type != switches::kRendererProcess &&
+ process_type != switches::kExtensionProcess)
sandbox_wrapper.InitializeSandbox(parsed_command_line, process_type);
#endif // OS_MACOSX
@@ -558,6 +559,10 @@ int ChromeMain(int argc, char** argv) {
int rv = -1;
if (process_type == switches::kRendererProcess) {
rv = RendererMain(main_params);
+ } else if (process_type == switches::kExtensionProcess) {
+ // An extension process is just a renderer process. We use a different
+ // command line argument to differentiate crash reports.
+ rv = RendererMain(main_params);
} else if (process_type == switches::kPluginProcess) {
rv = PluginMain(main_params);
} else if (process_type == switches::kUtilityProcess) {
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index c180fa0..a44eb55 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -200,7 +200,8 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_(
base::TimeDelta::FromSeconds(5),
this, &BrowserRenderProcessHost::ClearTransportDIBCache)),
- zygote_child_(false) {
+ zygote_child_(false),
+ extension_process_(false) {
widget_helper_ = new RenderWidgetHelper();
registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
@@ -263,8 +264,16 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() {
bool BrowserRenderProcessHost::Init(bool is_extensions_process) {
// calling Init() more than once does nothing, this makes it more convenient
// for the view host which may not be sure in some cases
- if (channel_.get())
+ if (channel_.get()) {
+ // Ensure that |is_extensions_process| doesn't change across multiple calls
+ // to Init().
+ if (!run_renderer_in_process()) {
+ DCHECK_EQ(extension_process_, is_extensions_process);
+ }
return true;
+ }
+
+ extension_process_ = is_extensions_process;
// run the IPC channel on the shared IO thread.
base::Thread* io_thread = g_browser_process->io_thread();
@@ -458,8 +467,11 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
command_line->AppendSwitch(switches::kNoErrorDialogs);
// Pass the process type first, so it shows first in process listings.
+ // Extensions use a special pseudo-process type to make them distinguishable,
+ // even though they're just renderers.
command_line->AppendSwitchWithValue(switches::kProcessType,
- switches::kRendererProcess);
+ extension_process_ ? switches::kExtensionProcess :
+ switches::kRendererProcess);
// Now send any options from our own command line we want to propogate.
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 762beff..42f6fe2 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -202,8 +202,13 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// True iff the renderer is a child of a zygote process.
bool zygote_child_;
+ // True iff this process is being used as an extension process. Not valid
+ // when running in single-process mode.
+ bool extension_process_;
+
base::Process process_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserRenderProcessHost);
};
diff --git a/chrome/browser/sandbox_policy.cc b/chrome/browser/sandbox_policy.cc
index 9b53eed..5d3dcfc 100644
--- a/chrome/browser/sandbox_policy.cc
+++ b/chrome/browser/sandbox_policy.cc
@@ -339,6 +339,9 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line,
std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType);
if (type_str == switches::kRendererProcess) {
type = ChildProcessInfo::RENDER_PROCESS;
+ } else if (type_str == switches::kExtensionProcess) {
+ // Extensions are just renderers with another name.
+ type = ChildProcessInfo::RENDER_PROCESS;
} else if (type_str == switches::kPluginProcess) {
type = ChildProcessInfo::PLUGIN_PROCESS;
} else if (type_str == switches::kWorkerProcess) {
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index d4230bc..839ef92 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -259,6 +259,9 @@ const char kExperimentalSpellcheckerFeatures[] =
// numbers.
const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports";
+// Causes the process to run as an extension subprocess.
+const char kExtensionProcess[] = "extension";
+
// Frequency in seconds for Extensions auto-update.
const char kExtensionsUpdateFrequency[] = "extensions-update-frequency";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index d778e3d..b276a09 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -87,6 +87,7 @@ extern const char kEnableUserScripts[];
extern const char kEnableWatchdog[];
extern const char kExperimentalSpellcheckerFeatures[];
extern const char kExplicitlyAllowedPorts[];
+extern const char kExtensionProcess[];
extern const char kExtensionsUpdateFrequency[];
extern const char kFileDescriptorLimit[];
extern const char kFirstRun[];
diff --git a/chrome/common/sandbox_init_wrapper_mac.cc b/chrome/common/sandbox_init_wrapper_mac.cc
index 6ce09d3..b57727b 100644
--- a/chrome/common/sandbox_init_wrapper_mac.cc
+++ b/chrome/common/sandbox_init_wrapper_mac.cc
@@ -22,6 +22,9 @@ bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
} else if (process_type == switches::kRendererProcess) {
// Renderer process sandbox.
sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER;
+ } else if (process_type == switches::kExtensionProcess) {
+ // Extension process sandbox.
+ sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER;
} else if (process_type == switches::kUtilityProcess) {
// Utility process sandbox.
sandbox_process_type = sandbox::SANDBOX_TYPE_UTILITY;
diff --git a/chrome/common/sandbox_init_wrapper_win.cc b/chrome/common/sandbox_init_wrapper_win.cc
index fe5c6df..0bfba24 100644
--- a/chrome/common/sandbox_init_wrapper_win.cc
+++ b/chrome/common/sandbox_init_wrapper_win.cc
@@ -19,6 +19,7 @@ bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
if (command_line.HasSwitch(switches::kNoSandbox))
return true;
if ((process_type == switches::kRendererProcess) ||
+ (process_type == switches::kExtensionProcess) ||
(process_type == switches::kWorkerProcess) ||
(process_type == switches::kNaClProcess) ||
(process_type == switches::kUtilityProcess) ||