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

Side by Side Diff: ppapi/proxy/plugin_main_nacl.cc

Issue 10905310: Start IPC-based NaCl PPAPI proxy after all untrusted code has loaded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | « ppapi/native_client/src/trusted/plugin/plugin.cc ('k') | no next file » | 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 // Need to include this before most other files because it defines 9 // Need to include this before most other files because it defines
10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define 10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define
11 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the 11 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the
12 // ViewMsgLog et al. functions. 12 // ViewMsgLog et al. functions.
13 13
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "ipc/ipc_channel_handle.h" 17 #include "ipc/ipc_channel_handle.h"
18 #include "ipc/ipc_logging.h" 18 #include "ipc/ipc_logging.h"
19 #include "ipc/ipc_message.h" 19 #include "ipc/ipc_message.h"
20 #include "native_client/src/shared/ppapi_proxy/ppruntime.h" 20 #include "native_client/src/shared/ppapi_proxy/ppruntime.h"
21 #include "native_client/src/shared/srpc/nacl_srpc.h"
21 #include "native_client/src/untrusted/irt/irt_ppapi.h" 22 #include "native_client/src/untrusted/irt/irt_ppapi.h"
22 #include "ppapi/c/ppp.h" 23 #include "ppapi/c/ppp.h"
23 #include "ppapi/c/ppp_instance.h" 24 #include "ppapi/c/ppp_instance.h"
24 #include "ppapi/proxy/plugin_dispatcher.h" 25 #include "ppapi/proxy/plugin_dispatcher.h"
25 #include "ppapi/proxy/plugin_globals.h" 26 #include "ppapi/proxy/plugin_globals.h"
26 #include "ppapi/proxy/plugin_proxy_delegate.h" 27 #include "ppapi/proxy/plugin_proxy_delegate.h"
27 #include "ppapi/shared_impl/ppb_audio_shared.h" 28 #include "ppapi/shared_impl/ppb_audio_shared.h"
28 29
29 #if defined(IPC_MESSAGE_LOG_ENABLED) 30 #if defined(IPC_MESSAGE_LOG_ENABLED)
30 #define IPC_MESSAGE_MACROS_LOG_ENABLED 31 #define IPC_MESSAGE_MACROS_LOG_ENABLED
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } // namespace 215 } // namespace
215 216
216 void PpapiPluginRegisterThreadCreator( 217 void PpapiPluginRegisterThreadCreator(
217 const struct PP_ThreadFunctions* thread_functions) { 218 const struct PP_ThreadFunctions* thread_functions) {
218 // Initialize all classes that need to create threads that call back into 219 // Initialize all classes that need to create threads that call back into
219 // user code. 220 // user code.
220 ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions); 221 ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions);
221 } 222 }
222 223
223 int IrtInit() { 224 int IrtInit() {
225 static int initialized = 0;
226 if (initialized) {
227 return 0;
228 }
229 if (!NaClSrpcModuleInit()) {
230 return 1;
231 }
232 initialized = 1;
224 return 0; 233 return 0;
225 } 234 }
226 235
227 int PpapiPluginMain() { 236 int PpapiPluginMain() {
228 base::AtExitManager exit_manager; 237 base::AtExitManager exit_manager;
229 MessageLoop loop; 238 MessageLoop loop;
230 IPC::Logging::set_log_function_map(&g_log_function_mapping); 239 IPC::Logging::set_log_function_map(&g_log_function_mapping);
231 ppapi::proxy::PluginGlobals plugin_globals; 240 ppapi::proxy::PluginGlobals plugin_globals;
232 base::Thread io_thread("Chrome_NaClIOThread"); 241 base::Thread io_thread("Chrome_NaClIOThread");
233 base::Thread::Options options; 242 base::Thread::Options options;
234 options.message_loop_type = MessageLoop::TYPE_IO; 243 options.message_loop_type = MessageLoop::TYPE_IO;
235 io_thread.StartWithOptions(options); 244 io_thread.StartWithOptions(options);
236 245
246 // Start up the SRPC server on another thread. Otherwise, when it blocks
247 // on an RPC, the PPAPI proxy will hang. Do this before we initialize the
248 // module and start the PPAPI proxy so that the NaCl plugin can continue
249 // loading the app.
250 static struct NaClSrpcHandlerDesc srpc_methods[] = { { NULL, NULL } };
251 if (!NaClSrpcAcceptClientOnThread(srpc_methods)) {
252 return 1;
253 }
254
237 int32_t error = ::PPP_InitializeModule( 255 int32_t error = ::PPP_InitializeModule(
238 0 /* module */, 256 0 /* module */,
239 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); 257 &ppapi::proxy::PluginDispatcher::GetBrowserInterface);
240 // TODO(dmichael): Handle other error conditions, like failure to connect? 258 // TODO(dmichael): Handle other error conditions, like failure to connect?
241 if (error) 259 if (error)
242 return error; 260 return error;
243 261
244 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); 262 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy());
245 263
246 loop.Run(); 264 loop.Run();
265
266 NaClSrpcModuleFini();
267
247 return 0; 268 return 0;
248 } 269 }
249 270
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/plugin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698