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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Forward all other control messages to the superclass. | 83 // Forward all other control messages to the superclass. |
84 IPC_MESSAGE_UNHANDLED(handled = Dispatcher::OnMessageReceived(msg)) | 84 IPC_MESSAGE_UNHANDLED(handled = Dispatcher::OnMessageReceived(msg)) |
85 IPC_END_MESSAGE_MAP() | 85 IPC_END_MESSAGE_MAP() |
86 return handled; | 86 return handled; |
87 } | 87 } |
88 | 88 |
89 // All non-control messages get handled by the superclass. | 89 // All non-control messages get handled by the superclass. |
90 return Dispatcher::OnMessageReceived(msg); | 90 return Dispatcher::OnMessageReceived(msg); |
91 } | 91 } |
92 | 92 |
| 93 void PluginDispatcher::DidCreateInstance(PP_Instance instance) { |
| 94 instance_map_[instance] = InstanceData(); |
| 95 } |
| 96 |
| 97 void PluginDispatcher::DidDestroyInstance(PP_Instance instance) { |
| 98 InstanceDataMap::iterator it = instance_map_.find(instance); |
| 99 if (it != instance_map_.end()) |
| 100 instance_map_.erase(it); |
| 101 } |
| 102 |
| 103 InstanceData* PluginDispatcher::GetInstanceData(PP_Instance instance) { |
| 104 InstanceDataMap::iterator it = instance_map_.find(instance); |
| 105 return (it == instance_map_.end()) ? NULL : &it->second; |
| 106 } |
| 107 |
93 void PluginDispatcher::OnMsgInitializeModule(PP_Module pp_module, | 108 void PluginDispatcher::OnMsgInitializeModule(PP_Module pp_module, |
94 bool* result) { | 109 bool* result) { |
95 set_pp_module(pp_module); | 110 set_pp_module(pp_module); |
96 *result = init_module_(pp_module, &GetInterfaceFromDispatcher) == PP_OK; | 111 *result = init_module_(pp_module, &GetInterfaceFromDispatcher) == PP_OK; |
97 } | 112 } |
98 | 113 |
99 void PluginDispatcher::OnMsgShutdown() { | 114 void PluginDispatcher::OnMsgShutdown() { |
100 if (shutdown_module_) | 115 if (shutdown_module_) |
101 shutdown_module_(); | 116 shutdown_module_(); |
102 MessageLoop::current()->Quit(); | 117 MessageLoop::current()->Quit(); |
103 } | 118 } |
104 | 119 |
105 } // namespace proxy | 120 } // namespace proxy |
106 } // namespace pp | 121 } // namespace pp |
107 | 122 |
OLD | NEW |