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

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: 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 should_use_zygote_(false),
44 #else 45 #else
45 child_flags_(CHILD_NORMAL), 46 child_flags_(CHILD_NORMAL),
46 #endif 47 #endif
47 started_(false) { 48 started_(false) {
48 } 49 }
49 50
50 UtilityProcessHost::~UtilityProcessHost() { 51 UtilityProcessHost::~UtilityProcessHost() {
51 DCHECK(!is_batch_mode_); 52 DCHECK(!is_batch_mode_);
52 } 53 }
53 54
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 107 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
107 if (browser_command_line.HasSwitch(switches::kChromeFrame)) 108 if (browser_command_line.HasSwitch(switches::kChromeFrame))
108 cmd_line->AppendSwitch(switches::kChromeFrame); 109 cmd_line->AppendSwitch(switches::kChromeFrame);
109 if (no_sandbox_ || browser_command_line.HasSwitch(switches::kNoSandbox)) 110 if (no_sandbox_ || browser_command_line.HasSwitch(switches::kNoSandbox))
110 cmd_line->AppendSwitch(switches::kNoSandbox); 111 cmd_line->AppendSwitch(switches::kNoSandbox);
111 if (browser_command_line.HasSwitch(switches::kDebugPluginLoading)) 112 if (browser_command_line.HasSwitch(switches::kDebugPluginLoading))
112 cmd_line->AppendSwitch(switches::kDebugPluginLoading); 113 cmd_line->AppendSwitch(switches::kDebugPluginLoading);
113 114
114 #if defined(OS_POSIX) 115 #if defined(OS_POSIX)
115 // TODO(port): Sandbox this on Linux. Also, zygote this to work with 116 // TODO(port): Sandbox extension unpacking on Linux.
116 // Linux updating.
117 bool has_cmd_prefix = browser_command_line.HasSwitch( 117 bool has_cmd_prefix = browser_command_line.HasSwitch(
118 switches::kUtilityCmdPrefix); 118 switches::kUtilityCmdPrefix);
119 if (has_cmd_prefix) { 119 if (has_cmd_prefix) {
120 // launch the utility child process with some prefix (usually "xterm -e gdb 120 // launch the utility child process with some prefix (usually "xterm -e gdb
121 // --args"). 121 // --args").
122 cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative( 122 cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative(
123 switches::kUtilityCmdPrefix)); 123 switches::kUtilityCmdPrefix));
124 } 124 }
125 125
126 cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_); 126 cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_);
127 #endif 127 #endif
128 128
129 bool use_zygote = false;
130
131 #if defined(OS_LINUX)
132 use_zygote = !no_sandbox_ && should_use_zygote_;
133 #endif
134
129 Launch( 135 Launch(
130 #if defined(OS_WIN) 136 #if defined(OS_WIN)
131 exposed_dir_, 137 exposed_dir_,
132 #elif defined(OS_POSIX) 138 #elif defined(OS_POSIX)
133 false, 139 use_zygote,
134 env_, 140 env_,
135 #endif 141 #endif
136 cmd_line); 142 cmd_line);
137 143
138 return true; 144 return true;
139 } 145 }
140 146
141 bool UtilityProcessHost::OnMessageReceived(const IPC::Message& message) { 147 bool UtilityProcessHost::OnMessageReceived(const IPC::Message& message) {
142 BrowserThread::PostTask( 148 BrowserThread::PostTask(
143 client_thread_id_, FROM_HERE, 149 client_thread_id_, FROM_HERE,
144 base::IgnoreReturn<bool>( 150 base::IgnoreReturn<bool>(
145 base::Bind(&Client::OnMessageReceived, client_.get(), message))); 151 base::Bind(&Client::OnMessageReceived, client_.get(), message)));
146 return true; 152 return true;
147 } 153 }
148 154
149 void UtilityProcessHost::OnProcessCrashed(int exit_code) { 155 void UtilityProcessHost::OnProcessCrashed(int exit_code) {
150 BrowserThread::PostTask( 156 BrowserThread::PostTask(
151 client_thread_id_, FROM_HERE, 157 client_thread_id_, FROM_HERE,
152 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code)); 158 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code));
153 } 159 }
154 160
155 bool UtilityProcessHost::CanShutdown() { 161 bool UtilityProcessHost::CanShutdown() {
156 return true; 162 return true;
157 } 163 }
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