diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 17:32:19 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 17:32:19 +0000 |
commit | 176c7392aadbb01cfd885e0a1aaea7e850d8d99a (patch) | |
tree | b39bae2c61985c991ee0591cdcb3e684a7389e2f | |
parent | d2bc6742a48ce48bd957cd812bf327dbfa7dce13 (diff) | |
download | chromium_src-176c7392aadbb01cfd885e0a1aaea7e850d8d99a.zip chromium_src-176c7392aadbb01cfd885e0a1aaea7e850d8d99a.tar.gz chromium_src-176c7392aadbb01cfd885e0a1aaea7e850d8d99a.tar.bz2 |
Implement PPAPI proxy shutdown.
This just adds a message from the dispatcher in the renderer to the one in
the plugin to terminate the process. The PpapiPluginProcessHost in the browser
automatically cleans everything up when there's an IPC channel error.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/5533002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68179 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/ppapi_plugin/ppapi_thread.cc | 8 | ||||
-rw-r--r-- | chrome/ppapi_plugin/ppapi_thread.h | 6 | ||||
-rw-r--r-- | ppapi/proxy/host_dispatcher.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.cc | 12 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.h | 5 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages_internal.h | 2 |
6 files changed, 25 insertions, 11 deletions
diff --git a/chrome/ppapi_plugin/ppapi_thread.cc b/chrome/ppapi_plugin/ppapi_thread.cc index 8c4da88..7d8eeda 100644 --- a/chrome/ppapi_plugin/ppapi_thread.cc +++ b/chrome/ppapi_plugin/ppapi_thread.cc @@ -37,7 +37,7 @@ PpapiThread::~PpapiThread() { // channel that ends up at Dispatcher::OnMessageReceived. void PpapiThread::OnMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) + IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) // The rest of the messages go to the dispatcher. /*IPC_MESSAGE_UNHANDLED( @@ -47,9 +47,9 @@ void PpapiThread::OnMessageReceived(const IPC::Message& msg) { IPC_END_MESSAGE_MAP() } -void PpapiThread::OnLoadPlugin(base::ProcessHandle host_process_handle, - const FilePath& path, - int renderer_id) { +void PpapiThread::OnMsgLoadPlugin(base::ProcessHandle host_process_handle, + const FilePath& path, + int renderer_id) { IPC::ChannelHandle channel_handle; if (!LoadPluginLib(host_process_handle, path) || !SetupRendererChannel(renderer_id, &channel_handle)) { diff --git a/chrome/ppapi_plugin/ppapi_thread.h b/chrome/ppapi_plugin/ppapi_thread.h index cf49c8b..215d1bd 100644 --- a/chrome/ppapi_plugin/ppapi_thread.h +++ b/chrome/ppapi_plugin/ppapi_thread.h @@ -35,9 +35,9 @@ class PpapiThread : public ChildThread { virtual void OnMessageReceived(const IPC::Message& msg); // Message handlers. - void OnLoadPlugin(base::ProcessHandle renderer_handle, - const FilePath& path, - int renderer_id); + void OnMsgLoadPlugin(base::ProcessHandle renderer_handle, + const FilePath& path, + int renderer_id); bool LoadPluginLib(base::ProcessHandle host_process_handle, const FilePath& path); diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc index a717af8..fd9801c 100644 --- a/ppapi/proxy/host_dispatcher.cc +++ b/ppapi/proxy/host_dispatcher.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "ppapi/proxy/host_var_serialization_rules.h" +#include "ppapi/proxy/ppapi_messages.h" namespace pp { namespace proxy { @@ -28,6 +29,8 @@ HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle, } HostDispatcher::~HostDispatcher() { + // Notify the plugin that it should exit. + Send(new PpapiMsg_Shutdown()); } // static diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index 4c9adca..037b470 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -70,7 +70,8 @@ void PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { if (msg.routing_id() == MSG_ROUTING_CONTROL) { // Handle some plugin-specific control messages. IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_InitializeModule, OnInitializeModule) + IPC_MESSAGE_HANDLER(PpapiMsg_InitializeModule, OnMsgInitializeModule) + IPC_MESSAGE_HANDLER(PpapiMsg_Shutdown, OnMsgShutdown) // Forward all other control messages to the superclass. IPC_MESSAGE_UNHANDLED(Dispatcher::OnMessageReceived(msg)) @@ -82,11 +83,18 @@ void PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { Dispatcher::OnMessageReceived(msg); } -void PluginDispatcher::OnInitializeModule(PP_Module pp_module, bool* result) { +void PluginDispatcher::OnMsgInitializeModule(PP_Module pp_module, + bool* result) { set_pp_module(pp_module); *result = init_module_(pp_module, &GetInterfaceFromDispatcher) == PP_OK; } +void PluginDispatcher::OnMsgShutdown() { + if (shutdown_module_) + shutdown_module_(); + MessageLoop::current()->Quit(); +} + } // namespace proxy } // namespace pp diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h index 79eafb1..8c75d33 100644 --- a/ppapi/proxy/plugin_dispatcher.h +++ b/ppapi/proxy/plugin_dispatcher.h @@ -61,8 +61,9 @@ class PluginDispatcher : public Dispatcher { } private: - // IPC message handler. - void OnInitializeModule(PP_Module pp_module, bool* result); + // IPC message handlers. + void OnMsgInitializeModule(PP_Module pp_module, bool* result); + void OnMsgShutdown(); InitModuleFunc init_module_; ShutdownModuleFunc shutdown_module_; diff --git a/ppapi/proxy/ppapi_messages_internal.h b/ppapi/proxy/ppapi_messages_internal.h index 1f854af..5259725 100644 --- a/ppapi/proxy/ppapi_messages_internal.h +++ b/ppapi/proxy/ppapi_messages_internal.h @@ -22,6 +22,8 @@ IPC_BEGIN_MESSAGES(Ppapi) PP_Module /* module_id */, bool /* result */) + IPC_MESSAGE_CONTROL0(PpapiMsg_Shutdown) + // Sent in both directions to see if the other side supports the given // interface. IPC_SYNC_MESSAGE_CONTROL1_1(PpapiMsg_SupportsInterface, |