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

Side by Side Diff: content/renderer/browser_plugin/guest_to_embedder_channel.h

Issue 9968097: Browser Plugin: Renderer-side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated to compile with clang Created 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
11 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
12 #include "content/renderer/render_view_impl.h"
13 #include "ipc/ipc_channel_handle.h"
14 #include "ppapi/c/pp_bool.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/shared_impl/ppb_view_shared.h"
17 #include "ppapi/proxy/plugin_dispatcher.h"
18 #include "ppapi/proxy/serialized_var.h"
19 #include "ppapi/shared_impl/host_resource.h"
20 #include "ppapi/shared_impl/ppapi_preferences.h"
21 #include "ppapi/shared_impl/ppb_input_event_shared.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
24
25 namespace content {
26
27 class BrowserPluginChannelManager;
28
29
Charlie Reis 2012/05/17 20:36:47 Extra line
Fady Samuel 2012/05/17 22:18:03 Done.
30 // GuestToEmbedderChannel is a Dispatcher that sends and receives ppapi messages
31 // from the browser plugin embedder. It is reference counted because it is held
32 // by a RenderViewImpl which (indirectly) owns a PpapiCommandBufferProxy through
33 // a WebGraphicsContext3DCommandBufferImpl which is owned by WebKit. Since the
34 // lifetime of this context is less than the lifetime of the RenderView, we keep
Charlie Reis 2012/05/17 20:36:47 nit: RenderView -> RenderViewImpl. (This is hard
Fady Samuel 2012/05/17 22:18:03 Done.
35 // the GuestToEmbedderChannel alive as long as a RenderViewImpl has access to
36 // it. If the context is lost, then the PpapiCommandBufferProxy is destroyed and
37 // we can safely release the reference to this GuestToEmbedderChannel held by
38 // RenderViewImpl.
39 class GuestToEmbedderChannel
40 : public ppapi::proxy::Dispatcher,
41 public base::RefCounted<GuestToEmbedderChannel> {
42 public:
43 explicit GuestToEmbedderChannel(const std::string& embedder_channel_manager);
44
45 virtual ~GuestToEmbedderChannel();
46
47 // This must be called before anything else. Returns true on success.
48 bool InitChannel(const IPC::ChannelHandle& channel_handle);
49
50 // Creates a new WebGraphicsContext3DCommandBufferImpl and returns it.
51 WebGraphicsContext3DCommandBufferImpl* CreateWebGraphicsContext3D(
52 RenderViewImpl* render_view,
53 const WebKit::WebGraphicsContext3D::Attributes& attributes,
54 bool offscreen);
55
56 // Inform the host to invalidate its plugin container after a swap buffer.
57 void IssueSwapBuffers(const ppapi::HostResource& resource);
58
59 // Request the receipt of events from the embedder renderer.
60 void RequestInputEvents(PP_Instance instance);
61
62 // Request a graphics context from the embedder renderer.
63 bool CreateGraphicsContext(
64 WebGraphicsContext3DCommandBufferImpl* context,
65 const WebKit::WebGraphicsContext3D::Attributes& attributes,
66 bool offscreen,
67 RenderViewImpl* render_view);
68
69 // Register the given RenderView with the given PP_Instance.
70 void AddGuest(PP_Instance instance, RenderViewImpl* render_view);
71
72 // Removes the guest with the given instance identifier from the
73 // InstanceMap.
74 void RemoveGuest(PP_Instance instance);
75
76 // ppapi::proxy::Dispatcher implementation.
77 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
78 virtual bool Send(IPC::Message* message) OVERRIDE;
79 virtual void OnChannelError() OVERRIDE;
80 virtual bool IsPlugin() const OVERRIDE;
81
82 private:
83 typedef std::map<PP_Instance, base::WeakPtr<RenderViewImpl> > InstanceMap;
84 typedef std::map<int, int> RoutingIDToInstanceMap;
85
86 void OnSupportsInterface(const std::string& interface_name, bool* result);
87 void OnSetPreferences(const ppapi::Preferences& prefs);
88 void OnReserveInstanceId(PP_Instance instance, bool* usable);
89 void OnDidCreate(PP_Instance instance,
90 const std::vector<std::string>& argn,
91 const std::vector<std::string>& argv,
92 PP_Bool* result);
93 void OnDidDestroy(PP_Instance instance);
94 void OnDidChangeView(PP_Instance instance,
95 const ppapi::ViewData& new_data,
96 PP_Bool flash_fullscreen);
97 void OnDidChangeFocus(PP_Instance instance, PP_Bool has_focus);
98 void OnGetInstanceObject(PP_Instance instance,
99 ppapi::proxy::SerializedVarReturnValue result);
100
101 void OnHandleMessage(PP_Instance instance,
102 ppapi::proxy::SerializedVarReceiveInput data);
103
104 void OnHandleFilteredInputEvent(PP_Instance instance,
105 const ppapi::InputEventData& data,
106 PP_Bool* result);
107
108 void OnSwapBuffersACK(const ppapi::HostResource& context,
109 int32_t pp_error);
110
111 void OnContextLost(PP_Instance instance);
112
113 base::WeakPtr<RenderViewImpl> render_view_;
114 BrowserPluginChannelManager* channel_manager_;
115 std::string embedder_channel_name_;
116 PepperProxyChannelDelegateImpl delegate_;
117
118 InstanceMap render_view_instances_;
119 RoutingIDToInstanceMap routing_id_instance_map_;
120
121 DISALLOW_COPY_AND_ASSIGN(GuestToEmbedderChannel);
122 };
123
124 } // namespace content
125
126 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698