summaryrefslogtreecommitdiffstats
path: root/chrome/browser/worker_host
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-21 20:32:30 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-21 20:32:30 +0000
commitfb1277e8766d447b967cfa959020b14c388e806e (patch)
tree1414679bfc830ff403c90fb1e8aa56a0180b514b /chrome/browser/worker_host
parent51549da314ab40bfce645bb6c5875c4e5ec12f67 (diff)
downloadchromium_src-fb1277e8766d447b967cfa959020b14c388e806e.zip
chromium_src-fb1277e8766d447b967cfa959020b14c388e806e.tar.gz
chromium_src-fb1277e8766d447b967cfa959020b14c388e806e.tar.bz2
Launch all child processes asynchronously so as not to block the IO thread.
BUG=6844, 27935 Review URL: http://codereview.chromium.org/402097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/worker_host')
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc49
1 files changed, 14 insertions, 35 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index b1e7e18f..0f6786b 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -9,12 +9,7 @@
#include "base/command_line.h"
#include "base/debug_util.h"
-#if defined(OS_POSIX)
-#include "base/global_descriptors_posix.h"
-#endif
#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/string_util.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/child_process_security_policy.h"
@@ -26,18 +21,12 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/debug_flags.h"
#include "chrome/common/notification_service.h"
-#include "chrome/common/process_watcher.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/result_codes.h"
#include "chrome/common/worker_messages.h"
-#include "ipc/ipc_descriptors.h"
#include "ipc/ipc_switches.h"
#include "net/base/registry_controlled_domain.h"
-#if defined(OS_WIN)
-#include "chrome/browser/sandbox_policy.h"
-#endif
-
// Notifies RenderViewHost that one or more worker objects crashed.
class WorkerCrashTask : public Task {
public:
@@ -94,45 +83,35 @@ bool WorkerProcessHost::Init() {
if (exe_path.empty())
return false;
- CommandLine cmd_line(exe_path);
- cmd_line.AppendSwitchWithValue(switches::kProcessType,
- switches::kWorkerProcess);
- cmd_line.AppendSwitchWithValue(switches::kProcessChannelID,
- ASCIIToWide(channel_id()));
- SetCrashReporterCommandLine(&cmd_line);
+ CommandLine* cmd_line = new CommandLine(exe_path);
+ cmd_line->AppendSwitchWithValue(switches::kProcessType,
+ switches::kWorkerProcess);
+ cmd_line->AppendSwitchWithValue(switches::kProcessChannelID,
+ ASCIIToWide(channel_id()));
+ SetCrashReporterCommandLine(cmd_line);
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNativeWebWorkers)) {
- cmd_line.AppendSwitch(switches::kEnableNativeWebWorkers);
+ cmd_line->AppendSwitch(switches::kEnableNativeWebWorkers);
}
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kWebWorkerShareProcesses)) {
- cmd_line.AppendSwitch(switches::kWebWorkerShareProcesses);
+ cmd_line->AppendSwitch(switches::kWebWorkerShareProcesses);
}
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kWorkerStartupDialog)) {
- cmd_line.AppendSwitch(switches::kWorkerStartupDialog);
+ cmd_line->AppendSwitch(switches::kWorkerStartupDialog);
}
- base::ProcessHandle process;
+ Launch(
#if defined(OS_WIN)
- process = sandbox::StartProcess(&cmd_line);
-#else
- // This code is duplicated with browser_render_process_host.cc, but
- // there's not a good place to de-duplicate it.
- base::file_handle_mapping_vector fds_to_map;
- const int ipcfd = channel().GetClientFileDescriptor();
- if (ipcfd > -1) {
- fds_to_map.push_back(std::pair<int, int>(
- ipcfd, kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
- }
- base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process);
+ FilePath(),
+#elif defined(OS_POSIX)
+ base::environment_vector(),
#endif
- if (!process)
- return false;
- SetHandle(process);
+ cmd_line);
ChildProcessSecurityPolicy::GetInstance()->Add(id());