OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/utility_process_host.h" | 5 #include "content/browser/utility_process_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 : BrowserChildProcessHost(content::PROCESS_TYPE_UTILITY), | 39 : BrowserChildProcessHost(content::PROCESS_TYPE_UTILITY), |
40 client_(client), | 40 client_(client), |
41 client_thread_id_(client_thread_id), | 41 client_thread_id_(client_thread_id), |
42 is_batch_mode_(false), | 42 is_batch_mode_(false), |
43 no_sandbox_(false), | 43 no_sandbox_(false), |
44 #if defined(OS_LINUX) | 44 #if defined(OS_LINUX) |
45 child_flags_(ChildProcessHost::CHILD_ALLOW_SELF), | 45 child_flags_(ChildProcessHost::CHILD_ALLOW_SELF), |
46 #else | 46 #else |
47 child_flags_(ChildProcessHost::CHILD_NORMAL), | 47 child_flags_(ChildProcessHost::CHILD_NORMAL), |
48 #endif | 48 #endif |
| 49 use_linux_zygote_(false), |
49 started_(false) { | 50 started_(false) { |
50 } | 51 } |
51 | 52 |
52 UtilityProcessHost::~UtilityProcessHost() { | 53 UtilityProcessHost::~UtilityProcessHost() { |
53 DCHECK(!is_batch_mode_); | 54 DCHECK(!is_batch_mode_); |
54 } | 55 } |
55 | 56 |
56 bool UtilityProcessHost::Send(IPC::Message* message) { | 57 bool UtilityProcessHost::Send(IPC::Message* message) { |
57 if (!StartProcess()) | 58 if (!StartProcess()) |
58 return false; | 59 return false; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (has_cmd_prefix) { | 123 if (has_cmd_prefix) { |
123 // launch the utility child process with some prefix (usually "xterm -e gdb | 124 // launch the utility child process with some prefix (usually "xterm -e gdb |
124 // --args"). | 125 // --args"). |
125 cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative( | 126 cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative( |
126 switches::kUtilityCmdPrefix)); | 127 switches::kUtilityCmdPrefix)); |
127 } | 128 } |
128 | 129 |
129 cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_); | 130 cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_); |
130 #endif | 131 #endif |
131 | 132 |
| 133 bool use_zygote = false; |
| 134 |
| 135 #if defined(OS_LINUX) |
| 136 use_zygote = !no_sandbox_ && use_linux_zygote_; |
| 137 #endif |
| 138 |
132 Launch( | 139 Launch( |
133 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
134 exposed_dir_, | 141 exposed_dir_, |
135 #elif defined(OS_POSIX) | 142 #elif defined(OS_POSIX) |
136 false, | 143 use_zygote, |
137 env_, | 144 env_, |
138 #endif | 145 #endif |
139 cmd_line); | 146 cmd_line); |
140 | 147 |
141 return true; | 148 return true; |
142 } | 149 } |
143 | 150 |
144 bool UtilityProcessHost::OnMessageReceived(const IPC::Message& message) { | 151 bool UtilityProcessHost::OnMessageReceived(const IPC::Message& message) { |
145 BrowserThread::PostTask( | 152 BrowserThread::PostTask( |
146 client_thread_id_, FROM_HERE, | 153 client_thread_id_, FROM_HERE, |
147 base::IgnoreReturn<bool>( | 154 base::IgnoreReturn<bool>( |
148 base::Bind(&Client::OnMessageReceived, client_.get(), message))); | 155 base::Bind(&Client::OnMessageReceived, client_.get(), message))); |
149 return true; | 156 return true; |
150 } | 157 } |
151 | 158 |
152 void UtilityProcessHost::OnProcessCrashed(int exit_code) { | 159 void UtilityProcessHost::OnProcessCrashed(int exit_code) { |
153 BrowserThread::PostTask( | 160 BrowserThread::PostTask( |
154 client_thread_id_, FROM_HERE, | 161 client_thread_id_, FROM_HERE, |
155 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code)); | 162 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code)); |
156 } | 163 } |
OLD | NEW |