| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/nacl/broker_thread.h" | 5 #include "chrome/nacl/broker_thread.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 base::ProcessHandle loader_handle_in_browser = 0; | 42 base::ProcessHandle loader_handle_in_browser = 0; |
| 43 | 43 |
| 44 // Create the path to the nacl broker/loader executable - it's the executable | 44 // Create the path to the nacl broker/loader executable - it's the executable |
| 45 // this code is running in. | 45 // this code is running in. |
| 46 FilePath exe_path; | 46 FilePath exe_path; |
| 47 PathService::Get(base::FILE_EXE, &exe_path); | 47 PathService::Get(base::FILE_EXE, &exe_path); |
| 48 if (!exe_path.empty()) { | 48 if (!exe_path.empty()) { |
| 49 CommandLine* cmd_line = new CommandLine(exe_path); | 49 CommandLine* cmd_line = new CommandLine(exe_path); |
| 50 nacl::CopyNaClCommandLineArguments(cmd_line); | 50 nacl::CopyNaClCommandLineArguments(cmd_line); |
| 51 | 51 |
| 52 cmd_line->AppendSwitchWithValue(switches::kProcessType, | 52 cmd_line->AppendSwitchASCII(switches::kProcessType, |
| 53 switches::kNaClLoaderProcess); | 53 switches::kNaClLoaderProcess); |
| 54 | 54 |
| 55 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, | 55 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, |
| 56 loader_channel_id); | 56 loader_channel_id); |
| 57 | 57 |
| 58 loader_process = sandbox::StartProcessWithAccess(cmd_line, FilePath()); | 58 loader_process = sandbox::StartProcessWithAccess(cmd_line, FilePath()); |
| 59 if (loader_process) { | 59 if (loader_process) { |
| 60 DuplicateHandle(::GetCurrentProcess(), loader_process, | 60 DuplicateHandle(::GetCurrentProcess(), loader_process, |
| 61 browser_handle_, &loader_handle_in_browser, | 61 browser_handle_, &loader_handle_in_browser, |
| 62 PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION , FALSE, 0); | 62 PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION , FALSE, 0); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id, | 65 Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id, |
| 66 loader_handle_in_browser)); | 66 loader_handle_in_browser)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void NaClBrokerThread::OnStopBroker() { | 69 void NaClBrokerThread::OnStopBroker() { |
| 70 ChildProcess::current()->ReleaseProcess(); | 70 ChildProcess::current()->ReleaseProcess(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void NaClBrokerThread::OnChannelConnected(int32 peer_pid) { | 73 void NaClBrokerThread::OnChannelConnected(int32 peer_pid) { |
| 74 bool res = base::OpenProcessHandle(peer_pid, &browser_handle_); | 74 bool res = base::OpenProcessHandle(peer_pid, &browser_handle_); |
| 75 DCHECK(res); | 75 DCHECK(res); |
| 76 ChildProcess::current()->AddRefProcess(); | 76 ChildProcess::current()->AddRefProcess(); |
| 77 } | 77 } |
| 78 | 78 |
| OLD | NEW |