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 "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 WebKit::initialize(webkit_platform_support_.get()); | 54 WebKit::initialize(webkit_platform_support_.get()); |
55 } | 55 } |
56 | 56 |
57 PpapiThread::~PpapiThread() { | 57 PpapiThread::~PpapiThread() { |
58 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); | 58 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); |
59 | 59 |
60 if (!library_.is_valid()) | 60 if (!library_.is_valid()) |
61 return; | 61 return; |
62 | 62 |
63 // The ShutdownModule/ShutdownBroker function is optional. | 63 // The ShutdownModule/ShutdownBroker function is optional. |
64 ppapi::proxy::ProxyChannel::ShutdownModuleFunc shutdown_function = | 64 PP_ShutdownModule_Func shutdown_function = |
65 is_broker_ ? | 65 is_broker_ ? |
66 reinterpret_cast<ppapi::proxy::ProxyChannel::ShutdownModuleFunc>( | 66 reinterpret_cast<PP_ShutdownModule_Func>( |
67 library_.GetFunctionPointer("PPP_ShutdownBroker")) : | 67 library_.GetFunctionPointer("PPP_ShutdownBroker")) : |
68 reinterpret_cast<ppapi::proxy::ProxyChannel::ShutdownModuleFunc>( | 68 reinterpret_cast<PP_ShutdownModule_Func>( |
69 library_.GetFunctionPointer("PPP_ShutdownModule")); | 69 library_.GetFunctionPointer("PPP_ShutdownModule")); |
70 if (shutdown_function) | 70 if (shutdown_function) |
71 shutdown_function(); | 71 shutdown_function(); |
72 WebKit::shutdown(); | 72 WebKit::shutdown(); |
73 } | 73 } |
74 | 74 |
75 // The "regular" ChildThread implements this function and does some standard | 75 // The "regular" ChildThread implements this function and does some standard |
76 // dispatching, then uses the message router. We don't actually need any of | 76 // dispatching, then uses the message router. We don't actually need any of |
77 // this so this function just overrides that one. | 77 // this so this function just overrides that one. |
78 // | 78 // |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 LOG(WARNING) << "InitBroker failed with error " << init_error; | 199 LOG(WARNING) << "InitBroker failed with error " << init_error; |
200 return; | 200 return; |
201 } | 201 } |
202 if (!connect_instance_func_) { | 202 if (!connect_instance_func_) { |
203 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; | 203 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; |
204 return; | 204 return; |
205 } | 205 } |
206 } else { | 206 } else { |
207 // Get the GetInterface function (required). | 207 // Get the GetInterface function (required). |
208 get_plugin_interface_ = | 208 get_plugin_interface_ = |
209 reinterpret_cast<ppapi::proxy::Dispatcher::GetInterfaceFunc>( | 209 reinterpret_cast<PP_GetInterface_Func>( |
210 library.GetFunctionPointer("PPP_GetInterface")); | 210 library.GetFunctionPointer("PPP_GetInterface")); |
211 if (!get_plugin_interface_) { | 211 if (!get_plugin_interface_) { |
212 LOG(WARNING) << "No PPP_GetInterface in plugin library"; | 212 LOG(WARNING) << "No PPP_GetInterface in plugin library"; |
213 return; | 213 return; |
214 } | 214 } |
215 | 215 |
216 #if defined(OS_MACOSX) | 216 #if defined(OS_MACOSX) |
217 // We need to do this after getting |PPP_GetInterface()| (or presumably | 217 // We need to do this after getting |PPP_GetInterface()| (or presumably |
218 // doing something nontrivial with the library), else the sandbox | 218 // doing something nontrivial with the library), else the sandbox |
219 // intercedes. | 219 // intercedes. |
220 if (!content::InitializeSandbox()) { | 220 if (!content::InitializeSandbox()) { |
221 LOG(WARNING) << "Failed to initialize sandbox"; | 221 LOG(WARNING) << "Failed to initialize sandbox"; |
222 } | 222 } |
223 #endif | 223 #endif |
224 | 224 |
225 // Get the InitializeModule function (required). | 225 // Get the InitializeModule function (required). |
226 ppapi::proxy::Dispatcher::InitModuleFunc init_module = | 226 PP_InitializeModule_Func init_module = |
227 reinterpret_cast<ppapi::proxy::Dispatcher::InitModuleFunc>( | 227 reinterpret_cast<PP_InitializeModule_Func>( |
228 library.GetFunctionPointer("PPP_InitializeModule")); | 228 library.GetFunctionPointer("PPP_InitializeModule")); |
229 if (!init_module) { | 229 if (!init_module) { |
230 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; | 230 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; |
231 return; | 231 return; |
232 } | 232 } |
233 int32_t init_error = init_module( | 233 int32_t init_error = init_module( |
234 local_pp_module_, | 234 local_pp_module_, |
235 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | 235 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); |
236 if (init_error != PP_OK) { | 236 if (init_error != PP_OK) { |
237 LOG(WARNING) << "InitModule failed with error " << init_error; | 237 LOG(WARNING) << "InitModule failed with error " << init_error; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 // From here, the dispatcher will manage its own lifetime according to the | 324 // From here, the dispatcher will manage its own lifetime according to the |
325 // lifetime of the attached channel. | 325 // lifetime of the attached channel. |
326 return true; | 326 return true; |
327 } | 327 } |
328 | 328 |
329 void PpapiThread::SavePluginName(const FilePath& path) { | 329 void PpapiThread::SavePluginName(const FilePath& path) { |
330 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 330 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
331 path.BaseName().AsUTF8Unsafe()); | 331 path.BaseName().AsUTF8Unsafe()); |
332 } | 332 } |
OLD | NEW |