Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: ppapi/proxy/plugin_dispatcher.cc

Issue 6905088: New thunk system for Pepper proxy and implementation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/plugin_dispatcher.h ('k') | ppapi/proxy/plugin_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
12 #include "ipc/ipc_sync_channel.h" 12 #include "ipc/ipc_sync_channel.h"
13 #include "gpu/common/gpu_trace_event.h" 13 #include "gpu/common/gpu_trace_event.h"
14 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/proxy/interface_proxy.h" 15 #include "ppapi/proxy/interface_proxy.h"
16 #include "ppapi/proxy/plugin_message_filter.h" 16 #include "ppapi/proxy/plugin_message_filter.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h"
17 #include "ppapi/proxy/plugin_var_serialization_rules.h" 18 #include "ppapi/proxy/plugin_var_serialization_rules.h"
18 #include "ppapi/proxy/ppapi_messages.h" 19 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/proxy/ppp_class_proxy.h" 20 #include "ppapi/proxy/ppp_class_proxy.h"
21 #include "ppapi/proxy/resource_creation_proxy.h"
22 #include "ppapi/shared_impl/tracker_base.h"
20 23
21 #if defined(OS_POSIX) 24 #if defined(OS_POSIX)
22 #include "base/eintr_wrapper.h" 25 #include "base/eintr_wrapper.h"
23 #include "ipc/ipc_channel_posix.h" 26 #include "ipc/ipc_channel_posix.h"
24 #endif 27 #endif
25 28
26 namespace pp { 29 namespace pp {
27 namespace proxy { 30 namespace proxy {
28 31
29 namespace { 32 namespace {
30 33
31 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap; 34 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap;
32 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; 35 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL;
33 36
34 } // namespace 37 } // namespace
35 38
36 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, 39 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle,
37 GetInterfaceFunc get_interface) 40 GetInterfaceFunc get_interface)
38 : Dispatcher(remote_process_handle, get_interface) { 41 : Dispatcher(remote_process_handle, get_interface) {
39 SetSerializationRules(new PluginVarSerializationRules); 42 SetSerializationRules(new PluginVarSerializationRules);
40 43
41 // As a plugin, we always support the PPP_Class interface. There's no 44 // As a plugin, we always support the PPP_Class interface. There's no
42 // GetInterface call or name for it, so we insert it into our table now. 45 // GetInterface call or name for it, so we insert it into our table now.
43 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); 46 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this));
47
48 ::ppapi::shared_impl::TrackerBase::Init(
49 &PluginResourceTracker::GetTrackerBaseInstance);
44 } 50 }
45 51
46 PluginDispatcher::~PluginDispatcher() { 52 PluginDispatcher::~PluginDispatcher() {
47 } 53 }
48 54
49 // static 55 // static
50 PluginDispatcher* PluginDispatcher::GetForInstance(PP_Instance instance) { 56 PluginDispatcher* PluginDispatcher::GetForInstance(PP_Instance instance) {
51 if (!g_instance_to_dispatcher) 57 if (!g_instance_to_dispatcher)
52 return NULL; 58 return NULL;
53 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( 59 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 NOTREACHED(); 194 NOTREACHED();
189 } 195 }
190 } 196 }
191 } 197 }
192 198
193 InstanceData* PluginDispatcher::GetInstanceData(PP_Instance instance) { 199 InstanceData* PluginDispatcher::GetInstanceData(PP_Instance instance) {
194 InstanceDataMap::iterator it = instance_map_.find(instance); 200 InstanceDataMap::iterator it = instance_map_.find(instance);
195 return (it == instance_map_.end()) ? NULL : &it->second; 201 return (it == instance_map_.end()) ? NULL : &it->second;
196 } 202 }
197 203
204 ::ppapi::shared_impl::FunctionGroupBase* PluginDispatcher::GetFunctionAPI(
205 pp::proxy::InterfaceID id) {
206 if (function_proxies_[id].get())
207 return function_proxies_[id].get();
208
209 if (id == INTERFACE_ID_RESOURCE_CREATION)
210 function_proxies_[id].reset(new ResourceCreationProxy(this));
211
212 return function_proxies_[id].get();
213 }
214
198 void PluginDispatcher::ForceFreeAllInstances() { 215 void PluginDispatcher::ForceFreeAllInstances() {
199 if (!g_instance_to_dispatcher) 216 if (!g_instance_to_dispatcher)
200 return; 217 return;
201 218
202 // Iterating will remove each item from the map, so we need to make a copy 219 // Iterating will remove each item from the map, so we need to make a copy
203 // to avoid things changing out from under is. 220 // to avoid things changing out from under is.
204 InstanceToDispatcherMap temp_map = *g_instance_to_dispatcher; 221 InstanceToDispatcherMap temp_map = *g_instance_to_dispatcher;
205 for (InstanceToDispatcherMap::iterator i = temp_map.begin(); 222 for (InstanceToDispatcherMap::iterator i = temp_map.begin();
206 i != temp_map.end(); ++i) { 223 i != temp_map.end(); ++i) {
207 if (i->second == this) { 224 if (i->second == this) {
(...skipping 26 matching lines...) Expand all
234 if (!interface_functions) 251 if (!interface_functions)
235 return; 252 return;
236 target_proxies_[info->id].reset( 253 target_proxies_[info->id].reset(
237 info->create_proxy(this, interface_functions)); 254 info->create_proxy(this, interface_functions));
238 *result = true; 255 *result = true;
239 } 256 }
240 257
241 } // namespace proxy 258 } // namespace proxy
242 } // namespace pp 259 } // namespace pp
243 260
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_dispatcher.h ('k') | ppapi/proxy/plugin_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698