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

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

Issue 7044012: Support getting the font list in Pepper. This currently only works out of (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/ppapi_messages.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 "base/debug/trace_event.h" 13 #include "base/debug/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_resource_tracker.h"
18 #include "ppapi/proxy/plugin_var_serialization_rules.h" 18 #include "ppapi/proxy/plugin_var_serialization_rules.h"
19 #include "ppapi/proxy/ppapi_messages.h" 19 #include "ppapi/proxy/ppapi_messages.h"
20 #include "ppapi/proxy/ppb_font_proxy.h"
20 #include "ppapi/proxy/ppp_class_proxy.h" 21 #include "ppapi/proxy/ppp_class_proxy.h"
21 #include "ppapi/proxy/resource_creation_proxy.h" 22 #include "ppapi/proxy/resource_creation_proxy.h"
22 #include "ppapi/shared_impl/tracker_base.h" 23 #include "ppapi/shared_impl/tracker_base.h"
23 24
24 #if defined(OS_POSIX) 25 #if defined(OS_POSIX)
25 #include "base/eintr_wrapper.h" 26 #include "base/eintr_wrapper.h"
26 #include "ipc/ipc_channel_posix.h" 27 #include "ipc/ipc_channel_posix.h"
27 #endif 28 #endif
28 29
29 namespace pp { 30 namespace pp {
30 namespace proxy { 31 namespace proxy {
31 32
32 namespace { 33 namespace {
33 34
34 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap; 35 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap;
35 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; 36 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL;
36 37
37 } // namespace 38 } // namespace
38 39
39 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, 40 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle,
40 GetInterfaceFunc get_interface) 41 GetInterfaceFunc get_interface)
41 : Dispatcher(remote_process_handle, get_interface) { 42 : Dispatcher(remote_process_handle, get_interface),
43 plugin_delegate_(NULL) {
42 SetSerializationRules(new PluginVarSerializationRules); 44 SetSerializationRules(new PluginVarSerializationRules);
43 45
44 // As a plugin, we always support the PPP_Class interface. There's no 46 // As a plugin, we always support the PPP_Class interface. There's no
45 // GetInterface call or name for it, so we insert it into our table now. 47 // GetInterface call or name for it, so we insert it into our table now.
46 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); 48 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this));
47 49
48 ::ppapi::TrackerBase::Init( 50 ::ppapi::TrackerBase::Init(
49 &PluginResourceTracker::GetTrackerBaseInstance); 51 &PluginResourceTracker::GetTrackerBaseInstance);
50 } 52 }
51 53
(...skipping 15 matching lines...) Expand all
67 const void* PluginDispatcher::GetInterfaceFromDispatcher( 69 const void* PluginDispatcher::GetInterfaceFromDispatcher(
68 const char* interface) { 70 const char* interface) {
69 // All interfaces the plugin requests of the browser are "PPB". 71 // All interfaces the plugin requests of the browser are "PPB".
70 const InterfaceProxy::Info* info = GetPPBInterfaceInfo(interface); 72 const InterfaceProxy::Info* info = GetPPBInterfaceInfo(interface);
71 if (!info) 73 if (!info)
72 return NULL; 74 return NULL;
73 return info->interface_ptr; 75 return info->interface_ptr;
74 } 76 }
75 77
76 bool PluginDispatcher::InitPluginWithChannel( 78 bool PluginDispatcher::InitPluginWithChannel(
77 PluginDispatcher::Delegate* delegate, 79 PluginDelegate* delegate,
78 const IPC::ChannelHandle& channel_handle, 80 const IPC::ChannelHandle& channel_handle,
79 bool is_client) { 81 bool is_client) {
80 if (!Dispatcher::InitWithChannel(delegate, channel_handle, is_client)) 82 if (!Dispatcher::InitWithChannel(delegate, channel_handle, is_client))
81 return false; 83 return false;
82 SetDelegate(delegate); 84 plugin_delegate_ = delegate;
83 85
84 // The message filter will intercept and process certain messages directly 86 // The message filter will intercept and process certain messages directly
85 // on the I/O thread. 87 // on the I/O thread.
86 channel()->AddFilter( 88 channel()->AddFilter(
87 new PluginMessageFilter(delegate->GetGloballySeenInstanceIDSet())); 89 new PluginMessageFilter(delegate->GetGloballySeenInstanceIDSet()));
88 return true; 90 return true;
89 } 91 }
90 92
91 bool PluginDispatcher::IsPlugin() const { 93 bool PluginDispatcher::IsPlugin() const {
92 return true; 94 return true;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 200 }
199 201
200 InstanceData* PluginDispatcher::GetInstanceData(PP_Instance instance) { 202 InstanceData* PluginDispatcher::GetInstanceData(PP_Instance instance) {
201 InstanceDataMap::iterator it = instance_map_.find(instance); 203 InstanceDataMap::iterator it = instance_map_.find(instance);
202 return (it == instance_map_.end()) ? NULL : &it->second; 204 return (it == instance_map_.end()) ? NULL : &it->second;
203 } 205 }
204 206
205 void PluginDispatcher::PostToWebKitThread( 207 void PluginDispatcher::PostToWebKitThread(
206 const tracked_objects::Location& from_here, 208 const tracked_objects::Location& from_here,
207 const base::Closure& task) { 209 const base::Closure& task) {
208 return dispatcher_delegate_->PostToWebKitThread(from_here, task); 210 return plugin_delegate_->PostToWebKitThread(from_here, task);
211 }
212
213 bool PluginDispatcher::SendToBrowser(IPC::Message* msg) {
214 return plugin_delegate_->SendToBrowser(msg);
209 } 215 }
210 216
211 ppapi::WebKitForwarding* PluginDispatcher::GetWebKitForwarding() { 217 ppapi::WebKitForwarding* PluginDispatcher::GetWebKitForwarding() {
212 return dispatcher_delegate_->GetWebKitForwarding(); 218 return plugin_delegate_->GetWebKitForwarding();
213 } 219 }
214 220
215 ::ppapi::FunctionGroupBase* PluginDispatcher::GetFunctionAPI( 221 ::ppapi::FunctionGroupBase* PluginDispatcher::GetFunctionAPI(
216 pp::proxy::InterfaceID id) { 222 pp::proxy::InterfaceID id) {
217 if (function_proxies_[id].get()) 223 if (function_proxies_[id].get())
218 return function_proxies_[id].get(); 224 return function_proxies_[id].get();
219 225
220 if (id == INTERFACE_ID_RESOURCE_CREATION) 226 if (id == INTERFACE_ID_RESOURCE_CREATION)
221 function_proxies_[id].reset(new ResourceCreationProxy(this)); 227 function_proxies_[id].reset(new ResourceCreationProxy(this));
228 if (id == INTERFACE_ID_PPB_FONT)
229 function_proxies_[id].reset(new PPB_Font_Proxy(this, NULL));
222 230
223 return function_proxies_[id].get(); 231 return function_proxies_[id].get();
224 } 232 }
225 233
226 void PluginDispatcher::ForceFreeAllInstances() { 234 void PluginDispatcher::ForceFreeAllInstances() {
227 if (!g_instance_to_dispatcher) 235 if (!g_instance_to_dispatcher)
228 return; 236 return;
229 237
230 // Iterating will remove each item from the map, so we need to make a copy 238 // Iterating will remove each item from the map, so we need to make a copy
231 // to avoid things changing out from under is. 239 // to avoid things changing out from under is.
(...skipping 30 matching lines...) Expand all
262 if (!interface_functions) 270 if (!interface_functions)
263 return; 271 return;
264 target_proxies_[info->id].reset( 272 target_proxies_[info->id].reset(
265 info->create_proxy(this, interface_functions)); 273 info->create_proxy(this, interface_functions));
266 *result = true; 274 *result = true;
267 } 275 }
268 276
269 } // namespace proxy 277 } // namespace proxy
270 } // namespace pp 278 } // namespace pp
271 279
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_dispatcher.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698