| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_module.h" | 5 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 scoped_refptr<PluginModule> lib(new PluginModule()); | 347 scoped_refptr<PluginModule> lib(new PluginModule()); |
| 348 if (!lib->InitFromEntryPoints(entry_points)) | 348 if (!lib->InitFromEntryPoints(entry_points)) |
| 349 return NULL; | 349 return NULL; |
| 350 | 350 |
| 351 return lib; | 351 return lib; |
| 352 } | 352 } |
| 353 | 353 |
| 354 // static | 354 // static |
| 355 scoped_refptr<PluginModule> PluginModule::CreateOutOfProcessModule( | 355 scoped_refptr<PluginModule> PluginModule::CreateOutOfProcessModule( |
| 356 MessageLoop* ipc_message_loop, | 356 MessageLoop* ipc_message_loop, |
| 357 base::ProcessHandle plugin_process_handle, |
| 357 const IPC::ChannelHandle& handle, | 358 const IPC::ChannelHandle& handle, |
| 358 base::WaitableEvent* shutdown_event) { | 359 base::WaitableEvent* shutdown_event) { |
| 359 scoped_refptr<PluginModule> lib(new PluginModule); | 360 scoped_refptr<PluginModule> lib(new PluginModule); |
| 360 if (!lib->InitForOutOfProcess(ipc_message_loop, handle, shutdown_event)) | 361 if (!lib->InitForOutOfProcess(ipc_message_loop, plugin_process_handle, |
| 362 handle, shutdown_event)) |
| 361 return NULL; | 363 return NULL; |
| 362 return lib; | 364 return lib; |
| 363 } | 365 } |
| 364 | 366 |
| 365 // static | 367 // static |
| 366 const PPB_Core* PluginModule::GetCore() { | 368 const PPB_Core* PluginModule::GetCore() { |
| 367 return &core_interface; | 369 return &core_interface; |
| 368 } | 370 } |
| 369 | 371 |
| 370 bool PluginModule::InitFromEntryPoints(const EntryPoints& entry_points) { | 372 bool PluginModule::InitFromEntryPoints(const EntryPoints& entry_points) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 398 return false; | 400 return false; |
| 399 } | 401 } |
| 400 | 402 |
| 401 // We let InitFromEntryPoints() handle setting the all the internal state | 403 // We let InitFromEntryPoints() handle setting the all the internal state |
| 402 // of the object other than the |library_| reference. | 404 // of the object other than the |library_| reference. |
| 403 library_ = library; | 405 library_ = library; |
| 404 return true; | 406 return true; |
| 405 } | 407 } |
| 406 | 408 |
| 407 bool PluginModule::InitForOutOfProcess(MessageLoop* ipc_message_loop, | 409 bool PluginModule::InitForOutOfProcess(MessageLoop* ipc_message_loop, |
| 410 base::ProcessHandle remote_process, |
| 408 const IPC::ChannelHandle& handle, | 411 const IPC::ChannelHandle& handle, |
| 409 base::WaitableEvent* shutdown_event) { | 412 base::WaitableEvent* shutdown_event) { |
| 410 const PPB_Var_Deprecated* var_interface = | 413 const PPB_Var_Deprecated* var_interface = |
| 411 reinterpret_cast<const PPB_Var_Deprecated*>( | 414 reinterpret_cast<const PPB_Var_Deprecated*>( |
| 412 GetInterface(PPB_VAR_DEPRECATED_INTERFACE)); | 415 GetInterface(PPB_VAR_DEPRECATED_INTERFACE)); |
| 413 dispatcher_.reset(new pp::proxy::HostDispatcher(var_interface, | 416 dispatcher_.reset(new pp::proxy::HostDispatcher( |
| 414 pp_module(), &GetInterface)); | 417 remote_process, var_interface, pp_module(), &GetInterface)); |
| 415 | 418 |
| 416 #if defined(OS_POSIX) | 419 #if defined(OS_POSIX) |
| 417 // If we received a ChannelHandle, register it now. | 420 // If we received a ChannelHandle, register it now. |
| 418 if (handle.socket.fd >= 0) | 421 if (handle.socket.fd >= 0) |
| 419 IPC::AddChannelSocket(handle.name, handle.socket.fd); | 422 IPC::AddChannelSocket(handle.name, handle.socket.fd); |
| 420 #endif | 423 #endif |
| 421 | 424 |
| 422 if (!dispatcher_->InitWithChannel(ipc_message_loop, handle.name, true, | 425 if (!dispatcher_->InitWithChannel(ipc_message_loop, handle.name, true, |
| 423 shutdown_event)) { | 426 shutdown_event)) { |
| 424 dispatcher_.reset(); | 427 dispatcher_.reset(); |
| 425 return false; | 428 return false; |
| 426 } | 429 } |
| 427 | 430 |
| 428 bool init_result = false; | 431 bool init_result = false; |
| 429 dispatcher_->Send(new PpapiMsg_InitializeModule(pp_module(), &init_result)); | 432 dispatcher_->Send(new PpapiMsg_InitializeModule(pp_module(), &init_result)); |
| 430 | |
| 431 if (!init_result) { | 433 if (!init_result) { |
| 432 // TODO(brettw) does the module get unloaded in this case? | 434 // TODO(brettw) does the module get unloaded in this case? |
| 433 dispatcher_.reset(); | 435 dispatcher_.reset(); |
| 434 return false; | 436 return false; |
| 435 } | 437 } |
| 436 return true; | 438 return true; |
| 437 } | 439 } |
| 438 | 440 |
| 439 // static | 441 // static |
| 440 bool PluginModule::LoadEntryPoints(const base::NativeLibrary& library, | 442 bool PluginModule::LoadEntryPoints(const base::NativeLibrary& library, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 live_plugin_objects_.insert(plugin_object); | 546 live_plugin_objects_.insert(plugin_object); |
| 545 } | 547 } |
| 546 | 548 |
| 547 void PluginModule::RemovePluginObject(PluginObject* plugin_object) { | 549 void PluginModule::RemovePluginObject(PluginObject* plugin_object) { |
| 548 // Don't actually verify that the object is in the set since during module | 550 // Don't actually verify that the object is in the set since during module |
| 549 // deletion we'll be in the process of freeing them. | 551 // deletion we'll be in the process of freeing them. |
| 550 live_plugin_objects_.erase(plugin_object); | 552 live_plugin_objects_.erase(plugin_object); |
| 551 } | 553 } |
| 552 | 554 |
| 553 } // namespace pepper | 555 } // namespace pepper |
| OLD | NEW |