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

Side by Side Diff: chrome/nacl/broker_thread.cc

Issue 7863024: Make the NaCl windows 64 bit binaries not depend on chrome targets. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify chrome_exe.gypi Created 9 years, 3 months 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
« no previous file with comments | « chrome/nacl/broker_thread.h ('k') | chrome/nacl/nacl_broker_listener.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/nacl/broker_thread.h"
6
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/path_service.h"
10 #include "base/process_util.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/nacl_cmd_line.h"
13 #include "chrome/common/nacl_messages.h"
14 #include "content/common/child_process.h"
15 #include "content/common/sandbox_policy.h"
16 #include "ipc/ipc_switches.h"
17
18 NaClBrokerThread::NaClBrokerThread()
19 : browser_handle_(0),
20 broker_services_(NULL) {
21 }
22
23 NaClBrokerThread::~NaClBrokerThread() {
24 base::CloseProcessHandle(browser_handle_);
25 }
26
27 NaClBrokerThread* NaClBrokerThread::current() {
28 return static_cast<NaClBrokerThread*>(ChildThread::current());
29 }
30
31 bool NaClBrokerThread::OnControlMessageReceived(const IPC::Message& msg) {
32 bool handled = true;
33 IPC_BEGIN_MESSAGE_MAP(NaClBrokerThread, msg)
34 IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchLoaderThroughBroker,
35 OnLaunchLoaderThroughBroker)
36 IPC_MESSAGE_HANDLER(NaClProcessMsg_StopBroker, OnStopBroker)
37 IPC_MESSAGE_UNHANDLED(handled = false)
38 IPC_END_MESSAGE_MAP()
39 return handled;
40 }
41
42 void NaClBrokerThread::OnLaunchLoaderThroughBroker(
43 const std::wstring& loader_channel_id) {
44 base::ProcessHandle loader_process = 0;
45 base::ProcessHandle loader_handle_in_browser = 0;
46
47 // Create the path to the nacl broker/loader executable - it's the executable
48 // this code is running in.
49 FilePath exe_path;
50 PathService::Get(base::FILE_EXE, &exe_path);
51 if (!exe_path.empty()) {
52 CommandLine* cmd_line = new CommandLine(exe_path);
53 nacl::CopyNaClCommandLineArguments(cmd_line);
54
55 cmd_line->AppendSwitchASCII(switches::kProcessType,
56 switches::kNaClLoaderProcess);
57
58 // TODO(evanm): remove needless usage of wstring for channel id.
59 cmd_line->AppendSwitchASCII(switches::kProcessChannelID,
60 WideToASCII(loader_channel_id));
61
62 loader_process = sandbox::StartProcessWithAccess(cmd_line, FilePath());
63 if (loader_process) {
64 DuplicateHandle(::GetCurrentProcess(), loader_process,
65 browser_handle_, &loader_handle_in_browser,
66 PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION , FALSE, 0);
67 }
68 }
69 Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id,
70 loader_handle_in_browser));
71 }
72
73 void NaClBrokerThread::OnStopBroker() {
74 ChildProcess::current()->ReleaseProcess();
75 }
76
77 void NaClBrokerThread::OnChannelConnected(int32 peer_pid) {
78 bool res = base::OpenProcessHandle(peer_pid, &browser_handle_);
79 DCHECK(res);
80 ChildProcess::current()->AddRefProcess();
81 }
82
OLDNEW
« no previous file with comments | « chrome/nacl/broker_thread.h ('k') | chrome/nacl/nacl_broker_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698