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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 8787004: Make ChildProcessHost be used through an interface in content/public, instead of by inheritence. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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 | Annotate | Revision Log
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/nacl_host/nacl_process_host.h" 7 #include "chrome/browser/nacl_host/nacl_process_host.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <fcntl.h> 10 #include <fcntl.h>
11 #endif 11 #endif
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/memory/singleton.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/logging_chrome.h" 22 #include "chrome/common/logging_chrome.h"
22 #include "chrome/common/nacl_cmd_line.h" 23 #include "chrome/common/nacl_cmd_line.h"
23 #include "chrome/common/nacl_messages.h" 24 #include "chrome/common/nacl_messages.h"
24 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
25 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 26 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
26 #include "content/common/child_process_host.h" 27 #include "content/public/common/child_process_host.h"
27 #include "ipc/ipc_switches.h" 28 #include "ipc/ipc_switches.h"
28 #include "native_client/src/shared/imc/nacl_imc.h" 29 #include "native_client/src/shared/imc/nacl_imc.h"
29 30
30 #if defined(OS_POSIX) 31 #if defined(OS_POSIX)
31 #include "ipc/ipc_channel_posix.h" 32 #include "ipc/ipc_channel_posix.h"
32 #elif defined(OS_WIN) 33 #elif defined(OS_WIN)
33 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" 34 #include "chrome/browser/nacl_host/nacl_broker_service_win.h"
34 #endif 35 #endif
35 36
36 using content::BrowserThread; 37 using content::BrowserThread;
38 using content::ChildProcessHost;
37 39
38 namespace { 40 namespace {
39 41
40 void SetCloseOnExec(nacl::Handle fd) { 42 void SetCloseOnExec(nacl::Handle fd) {
41 #if defined(OS_POSIX) 43 #if defined(OS_POSIX)
42 int flags = fcntl(fd, F_GETFD); 44 int flags = fcntl(fd, F_GETFD);
43 CHECK_NE(flags, -1); 45 CHECK_NE(flags, -1);
44 int rc = fcntl(fd, F_SETFD, flags | FD_CLOEXEC); 46 int rc = fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
45 CHECK_EQ(rc, 0); 47 CHECK_EQ(rc, 0);
46 #endif 48 #endif
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (!LaunchSelLdr()) { 223 if (!LaunchSelLdr()) {
222 return false; 224 return false;
223 } 225 }
224 chrome_render_message_filter_ = chrome_render_message_filter; 226 chrome_render_message_filter_ = chrome_render_message_filter;
225 reply_msg_ = reply_msg; 227 reply_msg_ = reply_msg;
226 228
227 return true; 229 return true;
228 } 230 }
229 231
230 bool NaClProcessHost::LaunchSelLdr() { 232 bool NaClProcessHost::LaunchSelLdr() {
231 if (!child_process_host()->CreateChannel()) 233 std::string channel_id = child_process_host()->CreateChannel();
234 if (channel_id.empty())
232 return false; 235 return false;
233 236
234 CommandLine::StringType nacl_loader_prefix; 237 CommandLine::StringType nacl_loader_prefix;
235 #if defined(OS_POSIX) 238 #if defined(OS_POSIX)
236 nacl_loader_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueNative( 239 nacl_loader_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueNative(
237 switches::kNaClLoaderCmdPrefix); 240 switches::kNaClLoaderCmdPrefix);
238 #endif // defined(OS_POSIX) 241 #endif // defined(OS_POSIX)
239 242
240 // Build command line for nacl. 243 // Build command line for nacl.
241 244
(...skipping 14 matching lines...) Expand all
256 259
257 FilePath exe_path = ChildProcessHost::GetChildPath(flags); 260 FilePath exe_path = ChildProcessHost::GetChildPath(flags);
258 if (exe_path.empty()) 261 if (exe_path.empty())
259 return false; 262 return false;
260 263
261 CommandLine* cmd_line = new CommandLine(exe_path); 264 CommandLine* cmd_line = new CommandLine(exe_path);
262 nacl::CopyNaClCommandLineArguments(cmd_line); 265 nacl::CopyNaClCommandLineArguments(cmd_line);
263 266
264 cmd_line->AppendSwitchASCII(switches::kProcessType, 267 cmd_line->AppendSwitchASCII(switches::kProcessType,
265 switches::kNaClLoaderProcess); 268 switches::kNaClLoaderProcess);
266 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, 269 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
267 child_process_host()->channel_id());
268 if (logging::DialogsAreSuppressed()) 270 if (logging::DialogsAreSuppressed())
269 cmd_line->AppendSwitch(switches::kNoErrorDialogs); 271 cmd_line->AppendSwitch(switches::kNoErrorDialogs);
270 272
271 if (!nacl_loader_prefix.empty()) 273 if (!nacl_loader_prefix.empty())
272 cmd_line->PrependWrapper(nacl_loader_prefix); 274 cmd_line->PrependWrapper(nacl_loader_prefix);
273 275
274 // On Windows we might need to start the broker process to launch a new loader 276 // On Windows we might need to start the broker process to launch a new loader
275 #if defined(OS_WIN) 277 #if defined(OS_WIN)
276 if (RunningOnWOW64()) { 278 if (RunningOnWOW64()) {
277 return NaClBrokerService::GetInstance()->LaunchLoader( 279 return NaClBrokerService::GetInstance()->LaunchLoader(
278 this, ASCIIToWide(child_process_host()->channel_id())); 280 this, ASCIIToWide(channel_id));
279 } else { 281 } else {
280 BrowserChildProcessHost::Launch(FilePath(), cmd_line); 282 BrowserChildProcessHost::Launch(FilePath(), cmd_line);
281 } 283 }
282 #elif defined(OS_POSIX) 284 #elif defined(OS_POSIX)
283 BrowserChildProcessHost::Launch(nacl_loader_prefix.empty(), // use_zygote 285 BrowserChildProcessHost::Launch(nacl_loader_prefix.empty(), // use_zygote
284 base::environment_vector(), 286 base::environment_vector(),
285 cmd_line); 287 cmd_line);
286 #endif 288 #endif
287 289
288 return true; 290 return true;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 #endif 514 #endif
513 515
514 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); 516 Send(new NaClProcessMsg_Start(handles_for_sel_ldr));
515 internal_->sockets_for_sel_ldr.clear(); 517 internal_->sockets_for_sel_ldr.clear();
516 } 518 }
517 519
518 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { 520 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
519 NOTREACHED() << "Invalid message with type = " << msg.type(); 521 NOTREACHED() << "Invalid message with type = " << msg.type();
520 return false; 522 return false;
521 } 523 }
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_broker_host_win.cc ('k') | chrome/browser/service/service_process_control.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698