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

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

Issue 5701004: Rename ResourceMessageFilter to RenderMessageFilter, since that's what it act... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/browser/plugin_service.h » ('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) 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 "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/command_line.h" 13 #include "base/command_line.h"
14 #include "base/metrics/nacl_histogram.h" 14 #include "base/metrics/nacl_histogram.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/renderer_host/resource_message_filter.h" 16 #include "chrome/browser/renderer_host/render_message_filter.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/logging_chrome.h" 18 #include "chrome/common/logging_chrome.h"
19 #include "chrome/common/nacl_cmd_line.h" 19 #include "chrome/common/nacl_cmd_line.h"
20 #include "chrome/common/nacl_messages.h" 20 #include "chrome/common/nacl_messages.h"
21 #include "chrome/common/render_messages.h" 21 #include "chrome/common/render_messages.h"
22 #include "ipc/ipc_switches.h" 22 #include "ipc/ipc_switches.h"
23 23
24 #if defined(OS_POSIX) 24 #if defined(OS_POSIX)
25 #include "ipc/ipc_channel_posix.h" 25 #include "ipc/ipc_channel_posix.h"
26 #elif defined(OS_WIN) 26 #elif defined(OS_WIN)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 nacl::Close(sockets_for_renderer_[i]); 67 nacl::Close(sockets_for_renderer_[i]);
68 } 68 }
69 for (size_t i = 0; i < sockets_for_sel_ldr_.size(); i++) { 69 for (size_t i = 0; i < sockets_for_sel_ldr_.size(); i++) {
70 nacl::Close(sockets_for_sel_ldr_[i]); 70 nacl::Close(sockets_for_sel_ldr_[i]);
71 } 71 }
72 #endif 72 #endif
73 73
74 // OnProcessLaunched didn't get called because the process couldn't launch. 74 // OnProcessLaunched didn't get called because the process couldn't launch.
75 // Don't keep the renderer hanging. 75 // Don't keep the renderer hanging.
76 reply_msg_->set_reply_error(); 76 reply_msg_->set_reply_error();
77 resource_message_filter_->Send(reply_msg_); 77 render_message_filter_->Send(reply_msg_);
78 } 78 }
79 79
80 bool NaClProcessHost::Launch(ResourceMessageFilter* resource_message_filter, 80 bool NaClProcessHost::Launch(RenderMessageFilter* render_message_filter,
81 int socket_count, 81 int socket_count,
82 IPC::Message* reply_msg) { 82 IPC::Message* reply_msg) {
83 #ifdef DISABLE_NACL 83 #ifdef DISABLE_NACL
84 NOTIMPLEMENTED() << "Native Client disabled at build time"; 84 NOTIMPLEMENTED() << "Native Client disabled at build time";
85 return false; 85 return false;
86 #else 86 #else
87 // Place an arbitrary limit on the number of sockets to limit 87 // Place an arbitrary limit on the number of sockets to limit
88 // exposure in case the renderer is compromised. We can increase 88 // exposure in case the renderer is compromised. We can increase
89 // this if necessary. 89 // this if necessary.
90 if (socket_count > 8) { 90 if (socket_count > 8) {
(...skipping 18 matching lines...) Expand all
109 sockets_for_sel_ldr_.push_back(pair[1]); 109 sockets_for_sel_ldr_.push_back(pair[1]);
110 SetCloseOnExec(pair[0]); 110 SetCloseOnExec(pair[0]);
111 SetCloseOnExec(pair[1]); 111 SetCloseOnExec(pair[1]);
112 } 112 }
113 113
114 // Launch the process 114 // Launch the process
115 if (!LaunchSelLdr()) { 115 if (!LaunchSelLdr()) {
116 return false; 116 return false;
117 } 117 }
118 UmaNaclHistogramEnumeration(NACL_STARTED); 118 UmaNaclHistogramEnumeration(NACL_STARTED);
119 resource_message_filter_ = resource_message_filter; 119 render_message_filter_ = render_message_filter;
120 reply_msg_ = reply_msg; 120 reply_msg_ = reply_msg;
121 121
122 return true; 122 return true;
123 #endif // DISABLE_NACL 123 #endif // DISABLE_NACL
124 } 124 }
125 125
126 bool NaClProcessHost::LaunchSelLdr() { 126 bool NaClProcessHost::LaunchSelLdr() {
127 if (!CreateChannel()) 127 if (!CreateChannel())
128 return false; 128 return false;
129 129
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 void NaClProcessHost::OnProcessLaunched() { 179 void NaClProcessHost::OnProcessLaunched() {
180 std::vector<nacl::FileDescriptor> handles_for_renderer; 180 std::vector<nacl::FileDescriptor> handles_for_renderer;
181 base::ProcessHandle nacl_process_handle; 181 base::ProcessHandle nacl_process_handle;
182 182
183 for (size_t i = 0; i < sockets_for_renderer_.size(); i++) { 183 for (size_t i = 0; i < sockets_for_renderer_.size(); i++) {
184 #if defined(OS_WIN) 184 #if defined(OS_WIN)
185 // Copy the handle into the renderer process. 185 // Copy the handle into the renderer process.
186 HANDLE handle_in_renderer; 186 HANDLE handle_in_renderer;
187 DuplicateHandle(base::GetCurrentProcessHandle(), 187 DuplicateHandle(base::GetCurrentProcessHandle(),
188 reinterpret_cast<HANDLE>(sockets_for_renderer_[i]), 188 reinterpret_cast<HANDLE>(sockets_for_renderer_[i]),
189 resource_message_filter_->handle(), 189 render_message_filter_->handle(),
190 &handle_in_renderer, 190 &handle_in_renderer,
191 GENERIC_READ | GENERIC_WRITE, 191 GENERIC_READ | GENERIC_WRITE,
192 FALSE, 192 FALSE,
193 DUPLICATE_CLOSE_SOURCE); 193 DUPLICATE_CLOSE_SOURCE);
194 handles_for_renderer.push_back( 194 handles_for_renderer.push_back(
195 reinterpret_cast<nacl::FileDescriptor>(handle_in_renderer)); 195 reinterpret_cast<nacl::FileDescriptor>(handle_in_renderer));
196 #else 196 #else
197 // No need to dup the imc_handle - we don't pass it anywhere else so 197 // No need to dup the imc_handle - we don't pass it anywhere else so
198 // it cannot be closed. 198 // it cannot be closed.
199 nacl::FileDescriptor imc_handle; 199 nacl::FileDescriptor imc_handle;
200 imc_handle.fd = sockets_for_renderer_[i]; 200 imc_handle.fd = sockets_for_renderer_[i];
201 imc_handle.auto_close = true; 201 imc_handle.auto_close = true;
202 handles_for_renderer.push_back(imc_handle); 202 handles_for_renderer.push_back(imc_handle);
203 #endif 203 #endif
204 } 204 }
205 205
206 #if defined(OS_WIN) 206 #if defined(OS_WIN)
207 // Copy the process handle into the renderer process. 207 // Copy the process handle into the renderer process.
208 DuplicateHandle(base::GetCurrentProcessHandle(), 208 DuplicateHandle(base::GetCurrentProcessHandle(),
209 handle(), 209 handle(),
210 resource_message_filter_->handle(), 210 render_message_filter_->handle(),
211 &nacl_process_handle, 211 &nacl_process_handle,
212 PROCESS_DUP_HANDLE, 212 PROCESS_DUP_HANDLE,
213 FALSE, 213 FALSE,
214 0); 214 0);
215 #else 215 #else
216 // We use pid as process handle on Posix 216 // We use pid as process handle on Posix
217 nacl_process_handle = handle(); 217 nacl_process_handle = handle();
218 #endif 218 #endif
219 219
220 // Get the pid of the NaCl process 220 // Get the pid of the NaCl process
221 base::ProcessId nacl_process_id = base::GetProcId(handle()); 221 base::ProcessId nacl_process_id = base::GetProcId(handle());
222 222
223 ViewHostMsg_LaunchNaCl::WriteReplyParams( 223 ViewHostMsg_LaunchNaCl::WriteReplyParams(
224 reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id); 224 reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id);
225 resource_message_filter_->Send(reply_msg_); 225 render_message_filter_->Send(reply_msg_);
226 resource_message_filter_ = NULL; 226 render_message_filter_ = NULL;
227 reply_msg_ = NULL; 227 reply_msg_ = NULL;
228 sockets_for_renderer_.clear(); 228 sockets_for_renderer_.clear();
229 229
230 SendStartMessage(); 230 SendStartMessage();
231 } 231 }
232 232
233 void NaClProcessHost::SendStartMessage() { 233 void NaClProcessHost::SendStartMessage() {
234 std::vector<nacl::FileDescriptor> handles_for_sel_ldr; 234 std::vector<nacl::FileDescriptor> handles_for_sel_ldr;
235 for (size_t i = 0; i < sockets_for_sel_ldr_.size(); i++) { 235 for (size_t i = 0; i < sockets_for_sel_ldr_.size(); i++) {
236 #if defined(OS_WIN) 236 #if defined(OS_WIN)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (fnIsWow64Process != NULL) { 304 if (fnIsWow64Process != NULL) {
305 BOOL bIsWow64 = FALSE; 305 BOOL bIsWow64 = FALSE;
306 if (fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { 306 if (fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) {
307 if (bIsWow64) { 307 if (bIsWow64) {
308 running_on_wow64_ = true; 308 running_on_wow64_ = true;
309 } 309 }
310 } 310 }
311 } 311 }
312 } 312 }
313 #endif 313 #endif
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/browser/plugin_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698