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

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

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
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 #ifndef PPAPI_PROXY_PLUGIN_DISPATCHER_H_ 5 #ifndef PPAPI_PROXY_PLUGIN_DISPATCHER_H_
6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_ 6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 16 matching lines...) Expand all
27 27
28 // Used to keep track of per-instance data. 28 // Used to keep track of per-instance data.
29 struct InstanceData { 29 struct InstanceData {
30 InstanceData() : fullscreen(PP_FALSE) {} 30 InstanceData() : fullscreen(PP_FALSE) {}
31 PP_Rect position; 31 PP_Rect position;
32 PP_Bool fullscreen; 32 PP_Bool fullscreen;
33 }; 33 };
34 34
35 class PluginDispatcher : public Dispatcher { 35 class PluginDispatcher : public Dispatcher {
36 public: 36 public:
37 class PluginDelegate : public ProxyChannel::Delegate {
38 public:
39 // Returns the set used for globally uniquifying PP_Instances. This same
40 // set must be returned for all channels. This is required only for the
41 // plugin side, for the host side, the return value may be NULL.
viettrungluu 2011/05/18 21:07:46 s/,/;/ (only the first comma). (Admittedly, you're
brettw 2011/05/18 21:14:38 Actually, I should have deleted this since there's
42 //
43 // DEREFERENCE ONLY ON THE I/O THREAD.
44 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() = 0;
45
46 // Returns the WebKit forwarding object used to make calls into WebKit.
47 // Necessary only on the plugin side. The host side can return NULL.
48 virtual ppapi::WebKitForwarding* GetWebKitForwarding() = 0;
49
50 // Posts the given task to the WebKit thread associated with this plugin
51 // process. For host processes, this will not be called and can do
52 // nothing. The WebKit thread should be lazily created if it does not
53 // exist yet.
54 virtual void PostToWebKitThread(const tracked_objects::Location& from_here,
55 const base::Closure& task) = 0;
56
57 // Sends the given message to the browser. Identical semantics to
58 // IPC::Message::Sender interface.
59 virtual bool SendToBrowser(IPC::Message* msg) = 0;
60 };
61
37 // Constructor for the plugin side. The init and shutdown functions will be 62 // Constructor for the plugin side. The init and shutdown functions will be
38 // will be automatically called when requested by the renderer side. The 63 // will be automatically called when requested by the renderer side. The
39 // module ID will be set upon receipt of the InitializeModule message. 64 // module ID will be set upon receipt of the InitializeModule message.
40 // 65 //
41 // You must call InitPluginWithChannel after the constructor. 66 // You must call InitPluginWithChannel after the constructor.
42 PluginDispatcher(base::ProcessHandle remote_process_handle, 67 PluginDispatcher(base::ProcessHandle remote_process_handle,
43 GetInterfaceFunc get_interface); 68 GetInterfaceFunc get_interface);
44 virtual ~PluginDispatcher(); 69 virtual ~PluginDispatcher();
45 70
46 // The plugin side maintains a mapping from PP_Instance to Dispatcher so 71 // The plugin side maintains a mapping from PP_Instance to Dispatcher so
47 // that we can send the messages to the right channel if there are multiple 72 // that we can send the messages to the right channel if there are multiple
48 // renderers sharing the same plugin. This mapping is maintained by 73 // renderers sharing the same plugin. This mapping is maintained by
49 // DidCreateInstance/DidDestroyInstance. 74 // DidCreateInstance/DidDestroyInstance.
50 static PluginDispatcher* GetForInstance(PP_Instance instance); 75 static PluginDispatcher* GetForInstance(PP_Instance instance);
51 76
52 static const void* GetInterfaceFromDispatcher(const char* interface); 77 static const void* GetInterfaceFromDispatcher(const char* interface);
53 78
54 // You must call this function before anything else. Returns true on success. 79 // You must call this function before anything else. Returns true on success.
55 // The delegate pointer must outlive this class, ownership is not 80 // The delegate pointer must outlive this class, ownership is not
56 // transferred. 81 // transferred.
57 virtual bool InitPluginWithChannel(Dispatcher::Delegate* delegate, 82 bool InitPluginWithChannel(PluginDelegate* delegate,
58 const IPC::ChannelHandle& channel_handle, 83 const IPC::ChannelHandle& channel_handle,
59 bool is_client); 84 bool is_client);
60 85
61 // Dispatcher overrides. 86 // Dispatcher overrides.
62 virtual bool IsPlugin() const; 87 virtual bool IsPlugin() const;
63 virtual bool Send(IPC::Message* msg); 88 virtual bool Send(IPC::Message* msg);
64 89
65 // IPC::Channel::Listener implementation. 90 // IPC::Channel::Listener implementation.
66 virtual bool OnMessageReceived(const IPC::Message& msg); 91 virtual bool OnMessageReceived(const IPC::Message& msg);
67 virtual void OnChannelError(); 92 virtual void OnChannelError();
68 93
69 // Keeps track of which dispatcher to use for each instance, active instances 94 // Keeps track of which dispatcher to use for each instance, active instances
70 // and tracks associated data like the current size. 95 // and tracks associated data like the current size.
71 void DidCreateInstance(PP_Instance instance); 96 void DidCreateInstance(PP_Instance instance);
72 void DidDestroyInstance(PP_Instance instance); 97 void DidDestroyInstance(PP_Instance instance);
73 98
74 // Gets the data for an existing instance, or NULL if the instance id doesn't 99 // Gets the data for an existing instance, or NULL if the instance id doesn't
75 // correspond to a known instance. 100 // correspond to a known instance.
76 InstanceData* GetInstanceData(PP_Instance instance); 101 InstanceData* GetInstanceData(PP_Instance instance);
77 102
78 // Posts the given task to the WebKit thread. 103 // Posts the given task to the WebKit thread.
79 void PostToWebKitThread(const tracked_objects::Location& from_here, 104 void PostToWebKitThread(const tracked_objects::Location& from_here,
80 const base::Closure& task); 105 const base::Closure& task);
81 106
107 // Calls the PluginDelegate.SendToBrowser function.
108 bool SendToBrowser(IPC::Message* msg);
109
82 // Returns the WebKitForwarding object used to forward events to WebKit. 110 // Returns the WebKitForwarding object used to forward events to WebKit.
83 ppapi::WebKitForwarding* GetWebKitForwarding(); 111 ppapi::WebKitForwarding* GetWebKitForwarding();
84 112
85 // Returns the "new-style" function API for the given interface ID, creating 113 // Returns the "new-style" function API for the given interface ID, creating
86 // it if necessary. 114 // it if necessary.
87 // TODO(brettw) this is in progress. It should be merged with the target 115 // TODO(brettw) this is in progress. It should be merged with the target
88 // proxies so there is one list to consult. 116 // proxies so there is one list to consult.
89 ppapi::FunctionGroupBase* GetFunctionAPI( 117 ppapi::FunctionGroupBase* GetFunctionAPI(
90 pp::proxy::InterfaceID id); 118 pp::proxy::InterfaceID id);
91 119
92 private: 120 private:
93 friend class PluginDispatcherTest; 121 friend class PluginDispatcherTest;
94 122
95 // Notifies all live instances that they're now closed. This is used when 123 // Notifies all live instances that they're now closed. This is used when
96 // a renderer crashes or some other error is received. 124 // a renderer crashes or some other error is received.
97 void ForceFreeAllInstances(); 125 void ForceFreeAllInstances();
98 126
99 // IPC message handlers. 127 // IPC message handlers.
100 void OnMsgSupportsInterface(const std::string& interface_name, bool* result); 128 void OnMsgSupportsInterface(const std::string& interface_name, bool* result);
101 129
130 PluginDelegate* plugin_delegate_;
131
102 // All target proxies currently created. These are ones that receive 132 // All target proxies currently created. These are ones that receive
103 // messages. 133 // messages.
104 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; 134 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT];
105 135
106 // Function proxies created for "new-style" FunctionGroups. 136 // Function proxies created for "new-style" FunctionGroups.
107 // TODO(brettw) this is in progress. It should be merged with the target 137 // TODO(brettw) this is in progress. It should be merged with the target
108 // proxies so there is one list to consult. 138 // proxies so there is one list to consult.
109 scoped_ptr< ::ppapi::FunctionGroupBase > 139 scoped_ptr< ::ppapi::FunctionGroupBase >
110 function_proxies_[INTERFACE_ID_COUNT]; 140 function_proxies_[INTERFACE_ID_COUNT];
111 141
112 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; 142 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap;
113 InstanceDataMap instance_map_; 143 InstanceDataMap instance_map_;
114 144
115 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); 145 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher);
116 }; 146 };
117 147
118 } // namespace proxy 148 } // namespace proxy
119 } // namespace pp 149 } // namespace pp
120 150
121 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ 151 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698