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

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

Issue 10020002: Pass the nacl start parameters as a struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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/nacl/nacl_listener.h" 5 #include "chrome/nacl/nacl_listener.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 filter_.reset(new IPC::SyncMessageFilter(&shutdown_event_)); 145 filter_.reset(new IPC::SyncMessageFilter(&shutdown_event_));
146 channel_->AddFilter(filter_.get()); 146 channel_->AddFilter(filter_.get());
147 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); 147 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true);
148 main_loop_ = MessageLoop::current(); 148 main_loop_ = MessageLoop::current();
149 main_loop_->Run(); 149 main_loop_->Run();
150 } 150 }
151 151
152 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { 152 bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
153 bool handled = true; 153 bool handled = true;
154 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) 154 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg)
155 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr) 155 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnMsgStart)
156 IPC_MESSAGE_UNHANDLED(handled = false) 156 IPC_MESSAGE_UNHANDLED(handled = false)
157 IPC_END_MESSAGE_MAP() 157 IPC_END_MESSAGE_MAP()
158 return handled; 158 return handled;
159 } 159 }
160 160
161 void NaClListener::OnStartSelLdr(std::vector<nacl::FileDescriptor> handles, 161 void NaClListener::OnMsgStart(const nacl::NaClStartParams& params) {
162 const std::string& validation_cache_key,
163 const std::string& version,
164 bool enable_exception_handling) {
165 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); 162 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate();
166 if (args == NULL) { 163 if (args == NULL) {
167 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; 164 LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
168 return; 165 return;
169 } 166 }
170 167
168 std::vector<nacl::FileDescriptor> handles = params.handles;
169
171 #if defined(OS_LINUX) || defined(OS_MACOSX) 170 #if defined(OS_LINUX) || defined(OS_MACOSX)
172 args->create_memory_object_func = CreateMemoryObject; 171 args->create_memory_object_func = CreateMemoryObject;
173 # if defined(OS_MACOSX) 172 # if defined(OS_MACOSX)
174 CHECK(handles.size() >= 1); 173 CHECK(handles.size() >= 1);
175 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); 174 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]);
176 handles.pop_back(); 175 handles.pop_back();
177 # endif 176 # endif
178 #endif 177 #endif
179 178
180 CHECK(handles.size() >= 1); 179 CHECK(handles.size() >= 1);
181 NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]); 180 NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]);
182 handles.pop_back(); 181 handles.pop_back();
183 182
184 #if defined(OS_WIN) 183 #if defined(OS_WIN)
185 args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle), 184 args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle),
186 _O_RDONLY | _O_BINARY); 185 _O_RDONLY | _O_BINARY);
187 if (args->irt_fd < 0) { 186 if (args->irt_fd < 0) {
188 LOG(ERROR) << "_open_osfhandle() failed"; 187 LOG(ERROR) << "_open_osfhandle() failed";
189 return; 188 return;
190 } 189 }
191 #else 190 #else
192 args->irt_fd = irt_handle; 191 args->irt_fd = irt_handle;
193 #endif 192 #endif
194 193
195 if (CheckEnvVar("NACL_VALIDATION_CACHE", false)) { 194 if (CheckEnvVar("NACL_VALIDATION_CACHE", false)) {
196 LOG(INFO) << "NaCl validation cache enabled."; 195 LOG(INFO) << "NaCl validation cache enabled.";
197 // The cache structure is not freed and exists until the NaCl process exits. 196 // The cache structure is not freed and exists until the NaCl process exits.
198 args->validation_cache = CreateValidationCache( 197 args->validation_cache = CreateValidationCache(
199 new BrowserValidationDBProxy(this), validation_cache_key, version); 198 new BrowserValidationDBProxy(this), params.validation_cache_key,
199 params.version);
200 } 200 }
201 201
202 CHECK(handles.size() == 1); 202 CHECK(handles.size() == 1);
203 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); 203 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]);
204 args->enable_exception_handling = enable_exception_handling; 204 args->enable_exception_handling = params.enable_exception_handling;
205 args->enable_debug_stub = debug_enabled_; 205 args->enable_debug_stub = debug_enabled_;
206 NaClChromeMainStart(args); 206 NaClChromeMainStart(args);
207 NOTREACHED(); 207 NOTREACHED();
208 } 208 }
OLDNEW
« chrome/browser/nacl_host/nacl_process_host.cc ('K') | « chrome/nacl/nacl_listener.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698