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 |
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/untrusted/irt/irt_ppapi.h" | 21 #include "native_client/src/untrusted/irt/irt_ppapi.h" |
22 #include "ppapi/c/ppp.h" | 22 #include "ppapi/c/ppp.h" |
23 #include "ppapi/c/ppp_instance.h" | 23 #include "ppapi/c/ppp_instance.h" |
24 #include "ppapi/proxy/plugin_dispatcher.h" | 24 #include "ppapi/proxy/plugin_dispatcher.h" |
25 #include "ppapi/proxy/plugin_globals.h" | 25 #include "ppapi/proxy/plugin_globals.h" |
26 #include "ppapi/shared_impl/ppb_audio_shared.h" | |
26 | 27 |
27 #if defined(IPC_MESSAGE_LOG_ENABLED) | 28 #if defined(IPC_MESSAGE_LOG_ENABLED) |
28 #define IPC_MESSAGE_MACROS_LOG_ENABLED | 29 #define IPC_MESSAGE_MACROS_LOG_ENABLED |
29 #include "ppapi/proxy/ppapi_messages.h" | 30 #include "ppapi/proxy/ppapi_messages.h" |
30 #endif | 31 #endif |
31 | 32 |
32 // This must match up with NACL_CHROME_INITIAL_IPC_DESC, | 33 // This must match up with NACL_CHROME_INITIAL_IPC_DESC, |
33 // defined in sel_main_chrome.h | 34 // defined in sel_main_chrome.h |
34 #define NACL_IPC_FD 6 | 35 #define NACL_IPC_FD 6 |
35 | 36 |
36 using ppapi::proxy::PluginDispatcher; | 37 using ppapi::proxy::PluginDispatcher; |
37 using ppapi::proxy::PluginGlobals; | 38 using ppapi::proxy::PluginGlobals; |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 struct PP_ThreadFunctions thread_funcs; | |
42 | |
43 // Copied from src/content/ppapi_plugin/ppapi_thread. This is a minimal | 42 // Copied from src/content/ppapi_plugin/ppapi_thread. This is a minimal |
44 // implementation to get us started. | 43 // implementation to get us started. |
45 class PluginDispatcherDelegate : public PluginDispatcher::PluginDelegate { | 44 class PluginDispatcherDelegate : public PluginDispatcher::PluginDelegate { |
46 public: | 45 public: |
47 explicit PluginDispatcherDelegate( | 46 explicit PluginDispatcherDelegate( |
48 scoped_refptr<base::MessageLoopProxy> io_loop) | 47 scoped_refptr<base::MessageLoopProxy> io_loop) |
49 : message_loop_(io_loop), | 48 : message_loop_(io_loop), |
50 shutdown_event_(true, false) { | 49 shutdown_event_(true, false) { |
51 } | 50 } |
52 | 51 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 std::set<PP_Instance> instances_; | 93 std::set<PP_Instance> instances_; |
95 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; | 94 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; |
96 uint32 next_plugin_dispatcher_id_; | 95 uint32 next_plugin_dispatcher_id_; |
97 scoped_refptr<base::MessageLoopProxy> message_loop_; | 96 scoped_refptr<base::MessageLoopProxy> message_loop_; |
98 base::WaitableEvent shutdown_event_; | 97 base::WaitableEvent shutdown_event_; |
99 }; | 98 }; |
100 | 99 |
101 } // namespace | 100 } // namespace |
102 | 101 |
103 void PpapiPluginRegisterThreadCreator( | 102 void PpapiPluginRegisterThreadCreator( |
104 const struct PP_ThreadFunctions* new_funcs) { | 103 const struct PP_ThreadFunctions* thread_functions) { |
105 thread_funcs = *new_funcs; | 104 // Initialize all classes that need to create threads that call back into |
105 // user code. | |
106 ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions); | |
bbudge
2012/07/24 20:10:46
We have to call down to shared code rather than th
| |
106 } | 107 } |
107 | 108 |
108 int IrtInit() { | 109 int IrtInit() { |
109 return 0; | 110 return 0; |
110 } | 111 } |
111 | 112 |
112 int PpapiPluginMain() { | 113 int PpapiPluginMain() { |
113 base::AtExitManager exit_manager; | 114 base::AtExitManager exit_manager; |
114 MessageLoop loop; | 115 MessageLoop loop; |
115 IPC::Logging::set_log_function_map(&g_log_function_mapping); | 116 IPC::Logging::set_log_function_map(&g_log_function_mapping); |
(...skipping 15 matching lines...) Expand all Loading... | |
131 // TODO(dmichael) Figure out how to determine if we're in incognito | 132 // TODO(dmichael) Figure out how to determine if we're in incognito |
132 PluginDispatcher dispatcher(::PPP_GetInterface, false /* incognito */); | 133 PluginDispatcher dispatcher(::PPP_GetInterface, false /* incognito */); |
133 IPC::ChannelHandle channel_handle("NaCl IPC", | 134 IPC::ChannelHandle channel_handle("NaCl IPC", |
134 base::FileDescriptor(NACL_IPC_FD, false)); | 135 base::FileDescriptor(NACL_IPC_FD, false)); |
135 dispatcher.InitPluginWithChannel(&delegate, channel_handle, false); | 136 dispatcher.InitPluginWithChannel(&delegate, channel_handle, false); |
136 | 137 |
137 loop.Run(); | 138 loop.Run(); |
138 return 0; | 139 return 0; |
139 } | 140 } |
140 | 141 |
OLD | NEW |