Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Side by Side Diff: content/browser/utility_process_host.cc

Issue 8770025: Zygote most of the uses of the utility process on Linux (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make use_linux_zygote flag default to true, and remove the need for #ifdef's. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 23 matching lines...) Expand all
34 34
35 UtilityProcessHost::UtilityProcessHost(Client* client, 35 UtilityProcessHost::UtilityProcessHost(Client* client,
36 BrowserThread::ID client_thread_id) 36 BrowserThread::ID client_thread_id)
37 : BrowserChildProcessHost(content::PROCESS_TYPE_UTILITY), 37 : BrowserChildProcessHost(content::PROCESS_TYPE_UTILITY),
38 client_(client), 38 client_(client),
39 client_thread_id_(client_thread_id), 39 client_thread_id_(client_thread_id),
40 is_batch_mode_(false), 40 is_batch_mode_(false),
41 no_sandbox_(false), 41 no_sandbox_(false),
42 #if defined(OS_LINUX) 42 #if defined(OS_LINUX)
43 child_flags_(CHILD_ALLOW_SELF), 43 child_flags_(CHILD_ALLOW_SELF),
44 use_linux_zygote_(true),
44 #else 45 #else
45 child_flags_(CHILD_NORMAL), 46 child_flags_(CHILD_NORMAL),
47 use_linux_zygote_(false),
46 #endif 48 #endif
47 started_(false) { 49 started_(false) {
48 } 50 }
49 51
50 UtilityProcessHost::~UtilityProcessHost() { 52 UtilityProcessHost::~UtilityProcessHost() {
51 DCHECK(!is_batch_mode_); 53 DCHECK(!is_batch_mode_);
52 } 54 }
53 55
54 bool UtilityProcessHost::Send(IPC::Message* message) { 56 bool UtilityProcessHost::Send(IPC::Message* message) {
55 if (!StartProcess()) 57 if (!StartProcess())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 107
106 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 108 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
107 if (browser_command_line.HasSwitch(switches::kChromeFrame)) 109 if (browser_command_line.HasSwitch(switches::kChromeFrame))
108 cmd_line->AppendSwitch(switches::kChromeFrame); 110 cmd_line->AppendSwitch(switches::kChromeFrame);
109 if (no_sandbox_ || browser_command_line.HasSwitch(switches::kNoSandbox)) 111 if (no_sandbox_ || browser_command_line.HasSwitch(switches::kNoSandbox))
110 cmd_line->AppendSwitch(switches::kNoSandbox); 112 cmd_line->AppendSwitch(switches::kNoSandbox);
111 if (browser_command_line.HasSwitch(switches::kDebugPluginLoading)) 113 if (browser_command_line.HasSwitch(switches::kDebugPluginLoading))
112 cmd_line->AppendSwitch(switches::kDebugPluginLoading); 114 cmd_line->AppendSwitch(switches::kDebugPluginLoading);
113 115
114 #if defined(OS_POSIX) 116 #if defined(OS_POSIX)
115 // TODO(port): Sandbox this on Linux. Also, zygote this to work with 117 // TODO(port): Sandbox extension unpacking on Linux.
116 // Linux updating.
117 bool has_cmd_prefix = browser_command_line.HasSwitch( 118 bool has_cmd_prefix = browser_command_line.HasSwitch(
118 switches::kUtilityCmdPrefix); 119 switches::kUtilityCmdPrefix);
119 if (has_cmd_prefix) { 120 if (has_cmd_prefix) {
120 // launch the utility child process with some prefix (usually "xterm -e gdb 121 // launch the utility child process with some prefix (usually "xterm -e gdb
121 // --args"). 122 // --args").
122 cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative( 123 cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative(
123 switches::kUtilityCmdPrefix)); 124 switches::kUtilityCmdPrefix));
124 } 125 }
125 126
126 cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_); 127 cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_);
127 #endif 128 #endif
128 129
130 bool use_zygote = false;
131
132 #if defined(OS_LINUX)
133 use_zygote = !no_sandbox_ && use_linux_zygote_;
134 #endif
135
129 Launch( 136 Launch(
130 #if defined(OS_WIN) 137 #if defined(OS_WIN)
131 exposed_dir_, 138 exposed_dir_,
132 #elif defined(OS_POSIX) 139 #elif defined(OS_POSIX)
133 false, 140 use_zygote,
134 env_, 141 env_,
135 #endif 142 #endif
136 cmd_line); 143 cmd_line);
137 144
138 return true; 145 return true;
139 } 146 }
140 147
141 bool UtilityProcessHost::OnMessageReceived(const IPC::Message& message) { 148 bool UtilityProcessHost::OnMessageReceived(const IPC::Message& message) {
142 BrowserThread::PostTask( 149 BrowserThread::PostTask(
143 client_thread_id_, FROM_HERE, 150 client_thread_id_, FROM_HERE,
144 base::IgnoreReturn<bool>( 151 base::IgnoreReturn<bool>(
145 base::Bind(&Client::OnMessageReceived, client_.get(), message))); 152 base::Bind(&Client::OnMessageReceived, client_.get(), message)));
146 return true; 153 return true;
147 } 154 }
148 155
149 void UtilityProcessHost::OnProcessCrashed(int exit_code) { 156 void UtilityProcessHost::OnProcessCrashed(int exit_code) {
150 BrowserThread::PostTask( 157 BrowserThread::PostTask(
151 client_thread_id_, FROM_HERE, 158 client_thread_id_, FROM_HERE,
152 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code)); 159 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code));
153 } 160 }
154 161
155 bool UtilityProcessHost::CanShutdown() { 162 bool UtilityProcessHost::CanShutdown() {
156 return true; 163 return true;
157 } 164 }
OLDNEW
« content/browser/utility_process_host.h ('K') | « content/browser/utility_process_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698