OLD | NEW |
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 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 259 } |
260 initialized = 1; | 260 initialized = 1; |
261 return 0; | 261 return 0; |
262 } | 262 } |
263 | 263 |
264 int PpapiPluginMain() { | 264 int PpapiPluginMain() { |
265 IrtInit(); | 265 IrtInit(); |
266 | 266 |
267 // Though it isn't referenced here, we must instantiate an AtExitManager. | 267 // Though it isn't referenced here, we must instantiate an AtExitManager. |
268 base::AtExitManager exit_manager; | 268 base::AtExitManager exit_manager; |
269 MessageLoop loop; | 269 base::MessageLoop loop; |
270 IPC::Logging::set_log_function_map(&g_log_function_mapping); | 270 IPC::Logging::set_log_function_map(&g_log_function_mapping); |
271 ppapi::proxy::PluginGlobals plugin_globals; | 271 ppapi::proxy::PluginGlobals plugin_globals; |
272 base::Thread io_thread("Chrome_NaClIOThread"); | 272 base::Thread io_thread("Chrome_NaClIOThread"); |
273 base::Thread::Options options; | 273 base::Thread::Options options; |
274 options.message_loop_type = MessageLoop::TYPE_IO; | 274 options.message_loop_type = base::MessageLoop::TYPE_IO; |
275 io_thread.StartWithOptions(options); | 275 io_thread.StartWithOptions(options); |
276 | 276 |
277 // Start up the SRPC server on another thread. Otherwise, when it blocks | 277 // Start up the SRPC server on another thread. Otherwise, when it blocks |
278 // on an RPC, the PPAPI proxy will hang. Do this before we initialize the | 278 // on an RPC, the PPAPI proxy will hang. Do this before we initialize the |
279 // module and start the PPAPI proxy so that the NaCl plugin can continue | 279 // module and start the PPAPI proxy so that the NaCl plugin can continue |
280 // loading the app. | 280 // loading the app. |
281 static struct NaClSrpcHandlerDesc srpc_methods[] = { { NULL, NULL } }; | 281 static struct NaClSrpcHandlerDesc srpc_methods[] = { { NULL, NULL } }; |
282 if (!NaClSrpcAcceptClientOnThread(srpc_methods)) { | 282 if (!NaClSrpcAcceptClientOnThread(srpc_methods)) { |
283 return 1; | 283 return 1; |
284 } | 284 } |
285 | 285 |
286 int32_t error = ::PPP_InitializeModule( | 286 int32_t error = ::PPP_InitializeModule( |
287 0 /* module */, | 287 0 /* module */, |
288 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | 288 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); |
289 // TODO(dmichael): Handle other error conditions, like failure to connect? | 289 // TODO(dmichael): Handle other error conditions, like failure to connect? |
290 if (error) | 290 if (error) |
291 return error; | 291 return error; |
292 | 292 |
293 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); | 293 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); |
294 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); | 294 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); |
295 | 295 |
296 loop.Run(); | 296 loop.Run(); |
297 | 297 |
298 NaClSrpcModuleFini(); | 298 NaClSrpcModuleFini(); |
299 | 299 |
300 return 0; | 300 return 0; |
301 } | 301 } |
OLD | NEW |