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

Side by Side Diff: content/renderer/pepper/pepper_helper_impl.h

Issue 20777009: A few more cleanups to the pepper code. Dispatch IPCs in the sockets implementations directly by ha… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browsertest Created 7 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_
7 7
8 #include <map>
9 #include <set> 8 #include <set>
10 #include <string> 9 #include <string>
11 #include <vector>
12 10
13 #include "base/basictypes.h" 11 #include "base/basictypes.h"
14 #include "base/id_map.h" 12 #include "base/id_map.h"
15 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
18 #include "base/observer_list.h"
19 #include "content/public/renderer/render_view_observer.h" 16 #include "content/public/renderer/render_view_observer.h"
20 #include "content/renderer/pepper/pepper_browser_connection.h"
21 #include "content/renderer/pepper_helper.h" 17 #include "content/renderer/pepper_helper.h"
22 #include "ipc/ipc_platform_file.h"
23 #include "ppapi/c/pp_file_info.h" 18 #include "ppapi/c/pp_file_info.h"
24 #include "ppapi/c/ppb_tcp_socket.h" 19 #include "ppapi/c/ppb_tcp_socket.h"
25 #include "ppapi/c/private/ppb_tcp_socket_private.h" 20 #include "ppapi/c/private/ppb_tcp_socket_private.h"
26 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" 21 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h"
27 #include "ppapi/shared_impl/url_response_info_data.h"
28 #include "ui/base/ime/text_input_type.h" 22 #include "ui/base/ime/text_input_type.h"
29 23
30 namespace base { 24 namespace base {
31 class FilePath; 25 class FilePath;
32 } 26 }
33 27
34 namespace ppapi { 28 namespace ppapi {
35 class PepperFilePath;
36 class PpapiPermissions; 29 class PpapiPermissions;
37 class PPB_X509Certificate_Fields; 30 struct URLResponseInfoData;
38 namespace host {
39 class ResourceHost;
40 }
41 } 31 }
42 32
43 namespace WebKit { 33 namespace WebKit {
44 class WebGamepads; 34 class WebGamepads;
45 class WebURLResponse; 35 class WebURLResponse;
46 struct WebCompositionUnderline; 36 struct WebCompositionUnderline;
47 struct WebCursorInfo; 37 struct WebCursorInfo;
48 } 38 }
49 39
50 namespace content { 40 namespace content {
51 class ContextProviderCommandBuffer; 41 class ContextProviderCommandBuffer;
52 class GamepadSharedMemoryReader; 42 class GamepadSharedMemoryReader;
53 class PepperBroker; 43 class PepperBroker;
54 class PluginModule; 44 class PluginModule;
55 class PPB_Broker_Impl; 45 class PPB_Broker_Impl;
56 class PPB_TCPSocket_Private_Impl;
57 class RenderViewImpl; 46 class RenderViewImpl;
58 struct WebPluginInfo; 47 struct WebPluginInfo;
59 48
60 class PepperHelperImpl : public PepperHelper, 49 class PepperHelperImpl : public PepperHelper,
61 public base::SupportsWeakPtr<PepperHelperImpl>, 50 public base::SupportsWeakPtr<PepperHelperImpl>,
62 public RenderViewObserver { 51 public RenderViewObserver {
63 public: 52 public:
64 explicit PepperHelperImpl(RenderViewImpl* render_view); 53 explicit PepperHelperImpl(RenderViewImpl* render_view);
65 virtual ~PepperHelperImpl(); 54 virtual ~PepperHelperImpl();
66 55
67 RenderViewImpl* render_view() { return render_view_; } 56 RenderViewImpl* render_view() { return render_view_; }
68 57
69 PepperBrowserConnection* pepper_browser_connection() {
70 return &pepper_browser_connection_;
71 }
72
73 // A pointer is returned immediately, but it is not ready to be used until 58 // A pointer is returned immediately, but it is not ready to be used until
74 // BrokerConnected has been called. 59 // BrokerConnected has been called.
75 // The caller is responsible for calling Disconnect() on the returned pointer 60 // The caller is responsible for calling Disconnect() on the returned pointer
76 // to clean up the corresponding resources allocated during this call. 61 // to clean up the corresponding resources allocated during this call.
77 PepperBroker* ConnectToBroker(PPB_Broker_Impl* client); 62 PepperBroker* ConnectToBroker(PPB_Broker_Impl* client);
78 63
79 // Removes broker from pending_connect_broker_ if present. Returns true if so. 64 // Removes broker from pending_connect_broker_ if present. Returns true if so.
80 bool StopWaitingForBrokerConnection(PepperBroker* broker); 65 bool StopWaitingForBrokerConnection(PepperBroker* broker);
81 66
82 void RegisterTCPSocket(PPB_TCPSocket_Private_Impl* socket, uint32 socket_id);
83 void UnregisterTCPSocket(uint32 socket_id);
84 void TCPServerSocketStopListening(uint32 socket_id);
85
86 // Notifies that |instance| has changed the cursor. 67 // Notifies that |instance| has changed the cursor.
87 // This will update the cursor appearance if it is currently over the plugin 68 // This will update the cursor appearance if it is currently over the plugin
88 // instance. 69 // instance.
89 void DidChangeCursor(PepperPluginInstanceImpl* instance, 70 void DidChangeCursor(PepperPluginInstanceImpl* instance,
90 const WebKit::WebCursorInfo& cursor); 71 const WebKit::WebCursorInfo& cursor);
91 72
92 // Notifies that |instance| has received a mouse event. 73 // Notifies that |instance| has received a mouse event.
93 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance); 74 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
94 75
95 // Notification that the given plugin is focused or unfocused. 76 // Notification that the given plugin is focused or unfocused.
(...skipping 12 matching lines...) Expand all
108 void PluginSelectionChanged(PepperPluginInstanceImpl* instance); 89 void PluginSelectionChanged(PepperPluginInstanceImpl* instance);
109 90
110 // Indicates that the given instance has been created. 91 // Indicates that the given instance has been created.
111 void InstanceCreated(PepperPluginInstanceImpl* instance); 92 void InstanceCreated(PepperPluginInstanceImpl* instance);
112 93
113 // Indicates that the given instance is being destroyed. This is called from 94 // Indicates that the given instance is being destroyed. This is called from
114 // the destructor, so it's important that the instance is not dereferenced 95 // the destructor, so it's important that the instance is not dereferenced
115 // from this call. 96 // from this call.
116 void InstanceDeleted(PepperPluginInstanceImpl* instance); 97 void InstanceDeleted(PepperPluginInstanceImpl* instance);
117 98
118 // Sends an async IPC to open a local file.
119 typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)>
120 AsyncOpenFileCallback;
121 bool AsyncOpenFile(const base::FilePath& path,
122 int pp_open_flags,
123 const AsyncOpenFileCallback& callback);
124
125 // Retrieve current gamepad data. 99 // Retrieve current gamepad data.
126 void SampleGamepads(WebKit::WebGamepads* data); 100 void SampleGamepads(WebKit::WebGamepads* data);
127 101
128 // Notifies the plugin of the document load. This should initiate the call to 102 // Notifies the plugin of the document load. This should initiate the call to
129 // PPP_Instance.HandleDocumentLoad. 103 // PPP_Instance.HandleDocumentLoad.
130 // 104 //
131 // The loader object should set itself on the PluginInstance as the document 105 // The loader object should set itself on the PluginInstance as the document
132 // loader using set_document_loader. 106 // loader using set_document_loader.
133 void HandleDocumentLoad(PepperPluginInstanceImpl* instance, 107 void HandleDocumentLoad(PepperPluginInstanceImpl* instance,
134 const WebKit::WebURLResponse& response); 108 const WebKit::WebURLResponse& response);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const std::vector<WebKit::WebCompositionUnderline>& underlines, 145 const std::vector<WebKit::WebCompositionUnderline>& underlines,
172 int selection_start, 146 int selection_start,
173 int selection_end) OVERRIDE; 147 int selection_end) OVERRIDE;
174 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; 148 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE;
175 virtual void WillHandleMouseEvent() OVERRIDE; 149 virtual void WillHandleMouseEvent() OVERRIDE;
176 150
177 // RenderViewObserver implementation. 151 // RenderViewObserver implementation.
178 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 152 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
179 virtual void OnDestruct() OVERRIDE; 153 virtual void OnDestruct() OVERRIDE;
180 154
181 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id,
182 uint32 socket_id,
183 int32_t result,
184 const PP_NetAddress_Private& local_addr,
185 const PP_NetAddress_Private& remote_addr);
186 void OnTCPSocketSSLHandshakeACK(
187 uint32 plugin_dispatcher_id,
188 uint32 socket_id,
189 bool succeeded,
190 const ppapi::PPB_X509Certificate_Fields& certificate_fields);
191 void OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
192 uint32 socket_id,
193 int32_t result,
194 const std::string& data);
195 void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
196 uint32 socket_id,
197 int32_t result);
198 void OnTCPSocketSetOptionACK(uint32 plugin_dispatcher_id,
199 uint32 socket_id,
200 int32_t result);
201 void OnPpapiBrokerChannelCreated(int request_id, 155 void OnPpapiBrokerChannelCreated(int request_id,
202 base::ProcessId broker_pid, 156 base::ProcessId broker_pid,
203 const IPC::ChannelHandle& handle); 157 const IPC::ChannelHandle& handle);
204 void OnAsyncFileOpened(base::PlatformFileError error_code,
205 IPC::PlatformFileForTransit file_for_transit,
206 int message_id);
207 void OnPpapiBrokerPermissionResult(int request_id, bool result); 158 void OnPpapiBrokerPermissionResult(int request_id, bool result);
208 159
209 // Attempts to create a PPAPI plugin for the given filepath. On success, it 160 // Attempts to create a PPAPI plugin for the given filepath. On success, it
210 // will return the newly-created module. 161 // will return the newly-created module.
211 // 162 //
212 // There are two reasons for failure. The first is that the plugin isn't 163 // There are two reasons for failure. The first is that the plugin isn't
213 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set 164 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set
214 // to false and the caller may want to fall back on creating an NPAPI plugin. 165 // to false and the caller may want to fall back on creating an NPAPI plugin.
215 // the second is that the plugin failed to initialize. In this case, 166 // the second is that the plugin failed to initialize. In this case,
216 // |*pepper_plugin_was_registered| will be set to true and the caller should 167 // |*pepper_plugin_was_registered| will be set to true and the caller should
(...skipping 18 matching lines...) Expand all
235 186
236 void DidDataFromWebURLResponse( 187 void DidDataFromWebURLResponse(
237 PP_Instance pp_instance, 188 PP_Instance pp_instance,
238 const WebKit::WebURLResponse& response, 189 const WebKit::WebURLResponse& response,
239 int pending_host_id, 190 int pending_host_id,
240 const ppapi::URLResponseInfoData& data); 191 const ppapi::URLResponseInfoData& data);
241 192
242 // Pointer to the RenderView that owns us. 193 // Pointer to the RenderView that owns us.
243 RenderViewImpl* render_view_; 194 RenderViewImpl* render_view_;
244 195
245 // Connection for sending and receiving pepper host-related messages to/from
246 // the browser.
247 PepperBrowserConnection pepper_browser_connection_;
248
249 std::set<PepperPluginInstanceImpl*> active_instances_; 196 std::set<PepperPluginInstanceImpl*> active_instances_;
250 197
251 IDMap<AsyncOpenFileCallback> pending_async_open_files_;
252
253 IDMap<PPB_TCPSocket_Private_Impl> tcp_sockets_;
254
255 typedef IDMap<scoped_refptr<PepperBroker>, IDMapOwnPointer> BrokerMap; 198 typedef IDMap<scoped_refptr<PepperBroker>, IDMapOwnPointer> BrokerMap;
256 BrokerMap pending_connect_broker_; 199 BrokerMap pending_connect_broker_;
257 200
258 typedef IDMap<base::WeakPtr<PPB_Broker_Impl> > PermissionRequestMap; 201 typedef IDMap<base::WeakPtr<PPB_Broker_Impl> > PermissionRequestMap;
259 PermissionRequestMap pending_permission_requests_; 202 PermissionRequestMap pending_permission_requests_;
260 203
261 // Whether or not the focus is on a PPAPI plugin 204 // Whether or not the focus is on a PPAPI plugin
262 PepperPluginInstanceImpl* focused_plugin_; 205 PepperPluginInstanceImpl* focused_plugin_;
263 206
264 // Current text input composition text. Empty if no composition is in 207 // Current text input composition text. Empty if no composition is in
265 // progress. 208 // progress.
266 string16 composition_text_; 209 string16 composition_text_;
267 210
268 // The plugin instance that received the last mouse event. It is set to NULL 211 // The plugin instance that received the last mouse event. It is set to NULL
269 // if the last mouse event went to elements other than Pepper plugins. 212 // if the last mouse event went to elements other than Pepper plugins.
270 // |last_mouse_event_target_| is not owned by this class. We can know about 213 // |last_mouse_event_target_| is not owned by this class. We can know about
271 // when it is destroyed via InstanceDeleted(). 214 // when it is destroyed via InstanceDeleted().
272 PepperPluginInstanceImpl* last_mouse_event_target_; 215 PepperPluginInstanceImpl* last_mouse_event_target_;
273 216
274 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_; 217 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
275 218
276 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_; 219 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_;
277 220
278 DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl); 221 DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl);
279 }; 222 };
280 223
281 } // namespace content 224 } // namespace content
282 225
283 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ 226 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_graphics_2d_host.cc ('k') | content/renderer/pepper/pepper_helper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698