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/host_dispatcher.h" | 5 #include "ppapi/proxy/host_dispatcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ppapi/c/dev/ppb_var_deprecated.h" | 10 #include "ppapi/c/dev/ppb_var_deprecated.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const PPB_Var_Deprecated* var_interface = | 29 const PPB_Var_Deprecated* var_interface = |
30 static_cast<const PPB_Var_Deprecated*>( | 30 static_cast<const PPB_Var_Deprecated*>( |
31 local_get_interface(PPB_VAR_DEPRECATED_INTERFACE)); | 31 local_get_interface(PPB_VAR_DEPRECATED_INTERFACE)); |
32 SetSerializationRules(new HostVarSerializationRules(var_interface, module)); | 32 SetSerializationRules(new HostVarSerializationRules(var_interface, module)); |
33 | 33 |
34 memset(plugin_interface_support_, 0, | 34 memset(plugin_interface_support_, 0, |
35 sizeof(PluginInterfaceSupport) * INTERFACE_ID_COUNT); | 35 sizeof(PluginInterfaceSupport) * INTERFACE_ID_COUNT); |
36 } | 36 } |
37 | 37 |
38 HostDispatcher::~HostDispatcher() { | 38 HostDispatcher::~HostDispatcher() { |
39 // Notify the plugin that it should exit. | |
40 Send(new PpapiMsg_Shutdown()); | |
41 } | |
42 | |
43 bool HostDispatcher::InitializeModule() { | |
44 bool init_result = false; | |
45 Send(new PpapiMsg_InitializeModule(pp_module(), &init_result)); | |
46 return init_result; | |
47 } | 39 } |
48 | 40 |
49 // static | 41 // static |
50 HostDispatcher* HostDispatcher::GetForInstance(PP_Instance instance) { | 42 HostDispatcher* HostDispatcher::GetForInstance(PP_Instance instance) { |
51 if (!g_instance_to_dispatcher) | 43 if (!g_instance_to_dispatcher) |
52 return NULL; | 44 return NULL; |
53 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( | 45 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( |
54 instance); | 46 instance); |
55 if (found == g_instance_to_dispatcher->end()) | 47 if (found == g_instance_to_dispatcher->end()) |
56 return NULL; | 48 return NULL; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return true; | 101 return true; |
110 } | 102 } |
111 | 103 |
112 proxy = info->create_proxy(this, local_interface); | 104 proxy = info->create_proxy(this, local_interface); |
113 target_proxies_[info->id].reset(proxy); | 105 target_proxies_[info->id].reset(proxy); |
114 } | 106 } |
115 | 107 |
116 return proxy->OnMessageReceived(msg); | 108 return proxy->OnMessageReceived(msg); |
117 } | 109 } |
118 | 110 |
| 111 void HostDispatcher::OnChannelError() { |
| 112 // TODO(brettw) plugin has crashed, handle this. |
| 113 } |
| 114 |
119 const void* HostDispatcher::GetProxiedInterface(const std::string& interface) { | 115 const void* HostDispatcher::GetProxiedInterface(const std::string& interface) { |
120 // First see if we even have a proxy for this interface. | 116 // First see if we even have a proxy for this interface. |
121 const InterfaceProxy::Info* info = GetPPPInterfaceInfo(interface); | 117 const InterfaceProxy::Info* info = GetPPPInterfaceInfo(interface); |
122 if (!info) | 118 if (!info) |
123 return NULL; | 119 return NULL; |
124 | 120 |
125 if (plugin_interface_support_[static_cast<int>(info->id)] != | 121 if (plugin_interface_support_[static_cast<int>(info->id)] != |
126 INTERFACE_UNQUERIED) { | 122 INTERFACE_UNQUERIED) { |
127 // Already queried the plugin if it supports this interface. | 123 // Already queried the plugin if it supports this interface. |
128 if (plugin_interface_support_[info->id] == INTERFACE_SUPPORTED) | 124 if (plugin_interface_support_[info->id] == INTERFACE_SUPPORTED) |
129 return info->interface; | 125 return info->interface; |
130 return NULL; | 126 return NULL; |
131 } | 127 } |
132 | 128 |
133 // Need to re-query. Cache the result so we only do this once. | 129 // Need to re-query. Cache the result so we only do this once. |
134 bool supported = false; | 130 bool supported = false; |
135 Send(new PpapiMsg_SupportsInterface(interface, &supported)); | 131 Send(new PpapiMsg_SupportsInterface(interface, &supported)); |
136 plugin_interface_support_[static_cast<int>(info->id)] = | 132 plugin_interface_support_[static_cast<int>(info->id)] = |
137 supported ? INTERFACE_SUPPORTED : INTERFACE_UNSUPPORTED; | 133 supported ? INTERFACE_SUPPORTED : INTERFACE_UNSUPPORTED; |
138 | 134 |
139 if (supported) | 135 if (supported) |
140 return info->interface; | 136 return info->interface; |
141 return NULL; | 137 return NULL; |
142 } | 138 } |
143 | 139 |
144 } // namespace proxy | 140 } // namespace proxy |
145 } // namespace pp | 141 } // namespace pp |
146 | 142 |
OLD | NEW |