| 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 "ppapi/proxy/plugin_dispatcher.h" | 5 #include "ppapi/proxy/plugin_dispatcher.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // static | 63 // static |
| 64 void PluginDispatcher::SetGlobal(PluginDispatcher* dispatcher) { | 64 void PluginDispatcher::SetGlobal(PluginDispatcher* dispatcher) { |
| 65 DCHECK(!dispatcher || !g_dispatcher); | 65 DCHECK(!dispatcher || !g_dispatcher); |
| 66 g_dispatcher = dispatcher; | 66 g_dispatcher = dispatcher; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool PluginDispatcher::IsPlugin() const { | 69 bool PluginDispatcher::IsPlugin() const { |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { | 73 bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| 74 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 74 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 75 // Handle some plugin-specific control messages. | 75 // Handle some plugin-specific control messages. |
| 76 bool handled = true; |
| 76 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) | 77 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) |
| 77 IPC_MESSAGE_HANDLER(PpapiMsg_InitializeModule, OnMsgInitializeModule) | 78 IPC_MESSAGE_HANDLER(PpapiMsg_InitializeModule, OnMsgInitializeModule) |
| 78 IPC_MESSAGE_HANDLER(PpapiMsg_Shutdown, OnMsgShutdown) | 79 IPC_MESSAGE_HANDLER(PpapiMsg_Shutdown, OnMsgShutdown) |
| 79 | 80 |
| 80 // Forward all other control messages to the superclass. | 81 // Forward all other control messages to the superclass. |
| 81 IPC_MESSAGE_UNHANDLED(Dispatcher::OnMessageReceived(msg)) | 82 IPC_MESSAGE_UNHANDLED(handled = Dispatcher::OnMessageReceived(msg)) |
| 82 IPC_END_MESSAGE_MAP() | 83 IPC_END_MESSAGE_MAP() |
| 83 return; | 84 return handled; |
| 84 } | 85 } |
| 85 | 86 |
| 86 // All non-control messages get handled by the superclass. | 87 // All non-control messages get handled by the superclass. |
| 87 Dispatcher::OnMessageReceived(msg); | 88 return Dispatcher::OnMessageReceived(msg); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void PluginDispatcher::OnMsgInitializeModule(PP_Module pp_module, | 91 void PluginDispatcher::OnMsgInitializeModule(PP_Module pp_module, |
| 91 bool* result) { | 92 bool* result) { |
| 92 set_pp_module(pp_module); | 93 set_pp_module(pp_module); |
| 93 *result = init_module_(pp_module, &GetInterfaceFromDispatcher) == PP_OK; | 94 *result = init_module_(pp_module, &GetInterfaceFromDispatcher) == PP_OK; |
| 94 } | 95 } |
| 95 | 96 |
| 96 void PluginDispatcher::OnMsgShutdown() { | 97 void PluginDispatcher::OnMsgShutdown() { |
| 97 if (shutdown_module_) | 98 if (shutdown_module_) |
| 98 shutdown_module_(); | 99 shutdown_module_(); |
| 99 MessageLoop::current()->Quit(); | 100 MessageLoop::current()->Quit(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 } // namespace proxy | 103 } // namespace proxy |
| 103 } // namespace pp | 104 } // namespace pp |
| 104 | 105 |
| OLD | NEW |