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

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

Issue 10039001: NaCl: Supply Windows handle-passing function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix + comment Created 8 years, 8 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 | « no previous file | chrome/nacl/nacl_listener.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/nacl_host/nacl_process_host.h" 5 #include "chrome/browser/nacl_host/nacl_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #if defined(OS_POSIX) 43 #if defined(OS_POSIX)
44 #include <fcntl.h> 44 #include <fcntl.h>
45 45
46 #include "ipc/ipc_channel_posix.h" 46 #include "ipc/ipc_channel_posix.h"
47 #elif defined(OS_WIN) 47 #elif defined(OS_WIN)
48 #include <windows.h> 48 #include <windows.h>
49 49
50 #include "base/threading/thread.h" 50 #include "base/threading/thread.h"
51 #include "base/process_util.h" 51 #include "base/process_util.h"
52 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" 52 #include "chrome/browser/nacl_host/nacl_broker_service_win.h"
53 #include "content/public/common/sandbox_init.h"
53 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler. h" 54 #include "native_client/src/trusted/service_runtime/win/debug_exception_handler. h"
54 #endif 55 #endif
55 56
56 using content::BrowserThread; 57 using content::BrowserThread;
57 using content::ChildProcessData; 58 using content::ChildProcessData;
58 using content::ChildProcessHost; 59 using content::ChildProcessHost;
59 60
60 namespace { 61 namespace {
61 62
62 #if defined(OS_WIN) 63 #if defined(OS_WIN)
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 nacl::FileDescriptor imc_handle; 912 nacl::FileDescriptor imc_handle;
912 imc_handle.fd = internal_->sockets_for_renderer[i]; 913 imc_handle.fd = internal_->sockets_for_renderer[i];
913 imc_handle.auto_close = true; 914 imc_handle.auto_close = true;
914 handles_for_renderer.push_back(imc_handle); 915 handles_for_renderer.push_back(imc_handle);
915 #endif 916 #endif
916 } 917 }
917 918
918 const ChildProcessData& data = process_->GetData(); 919 const ChildProcessData& data = process_->GetData();
919 #if defined(OS_WIN) 920 #if defined(OS_WIN)
920 // Copy the process handle into the renderer process. 921 // Copy the process handle into the renderer process.
922 // TODO(mseaborn): Remove this. The renderer process uses this
923 // handle with NaCl's handle_pass module, but we are replacing
924 // handle_pass with Chrome's BrokerDuplicateHandle() function.
921 if (!DuplicateHandle(base::GetCurrentProcessHandle(), 925 if (!DuplicateHandle(base::GetCurrentProcessHandle(),
922 data.handle, 926 data.handle,
923 chrome_render_message_filter_->peer_handle(), 927 chrome_render_message_filter_->peer_handle(),
924 &nacl_process_handle, 928 &nacl_process_handle,
925 PROCESS_DUP_HANDLE, 929 PROCESS_DUP_HANDLE,
926 FALSE, 930 FALSE,
927 0)) { 931 0)) {
928 DLOG(ERROR) << "DuplicateHandle() failed"; 932 DLOG(ERROR) << "DuplicateHandle() failed";
929 return false; 933 return false;
930 } 934 }
935 // If we are on 64-bit Windows, the NaCl process's sandbox is
936 // managed by a different process from the renderer's sandbox. We
937 // need to inform the renderer's sandbox about the NaCl process so
938 // that the renderer can send handles to the NaCl process using
939 // BrokerDuplicateHandle().
940 if (RunningOnWOW64()) {
941 if (!content::BrokerAddTargetPeer(data.handle)) {
942 DLOG(ERROR) << "Failed to add NaCl process PID";
943 return false;
944 }
945 }
931 #else 946 #else
932 // We use pid as process handle on Posix 947 // We use pid as process handle on Posix
933 nacl_process_handle = data.handle; 948 nacl_process_handle = data.handle;
934 #endif 949 #endif
935 950
936 // Get the pid of the NaCl process 951 // Get the pid of the NaCl process
937 base::ProcessId nacl_process_id = base::GetProcId(data.handle); 952 base::ProcessId nacl_process_id = base::GetProcId(data.handle);
938 953
939 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( 954 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
940 reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id); 955 reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 } 1040 }
1026 1041
1027 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature, 1042 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature,
1028 bool* result) { 1043 bool* result) {
1029 *result = NaClBrowser::GetInstance()->QueryKnownToValidate(signature); 1044 *result = NaClBrowser::GetInstance()->QueryKnownToValidate(signature);
1030 } 1045 }
1031 1046
1032 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { 1047 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) {
1033 NaClBrowser::GetInstance()->SetKnownToValidate(signature); 1048 NaClBrowser::GetInstance()->SetKnownToValidate(signature);
1034 } 1049 }
OLDNEW
« no previous file with comments | « no previous file | chrome/nacl/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698