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

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

Issue 9609008: Implemented Browser Plugin (NOT FOR REVIEW) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated according to creis@'s comments 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 // GuestToEmbedderChannel is a Dispatcher that sends and receives ppapi messages
30 // from the browser plugin embedder. It is reference counted because it is held
31 // by a RenderViewImpl which (indirectly) owns a PpapiCommandBufferProxy through
32 // a WebGraphicsContext3DCommandBufferImpl which is owned by WebKit. Since the
33 // lifetime of this context is less than the lifetime of the RenderViewImpl, we
34 // keep the GuestToEmbedderChannel alive as long as a RenderViewImpl has access
35 // to it. If the context is lost, then the PpapiCommandBufferProxy is destroyed
36 // and we can safely release the reference to this GuestToEmbedderChannel held
37 // by RenderViewImpl.
38 class GuestToEmbedderChannel
39 : public ppapi::proxy::Dispatcher,
40 public base::RefCounted<GuestToEmbedderChannel> {
41 public:
42 explicit GuestToEmbedderChannel(const std::string& embedder_channel_manager);
43
44 virtual ~GuestToEmbedderChannel() { }
45
46 // This must be called before anything else. Returns true on success.
47 bool InitChannel(const IPC::ChannelHandle& channel_handle);
48
49 // Creates a new WebGraphicsContext3DCommandBufferImpl and returns it.
50 WebGraphicsContext3DCommandBufferImpl* CreateWebGraphicsContext3D(
51 RenderViewImpl* render_view,
52 const WebKit::WebGraphicsContext3D::Attributes& attributes,
53 bool offscreen);
54
55 // Inform the host to invalidate its plugin container after a swap buffer.
56 void IssueSwapBuffers(const ppapi::HostResource& resource);
57
58 // Request the receipt of events from the embedder renderer.
59 void RequestInputEvents(PP_Instance instance);
60
61 // Request a graphics context from the embedder renderer.
62 bool CreateGraphicsContext(
63 WebGraphicsContext3DCommandBufferImpl* context,
64 const WebKit::WebGraphicsContext3D::Attributes& attributes,
65 bool offscreen,
66 RenderViewImpl* render_view);
67
68 // Register the given RenderView with the given PP_Instance.
69 void AddGuest(PP_Instance instance, RenderViewImpl* render_view);
70
71 // Removes the guest with the given instance identifier from the
72 // InstanceMap.
73 void RemoveGuest(PP_Instance instance);
74
75 // ppapi::proxy::Dispatcher implementation.
76 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
77 virtual bool Send(IPC::Message* message) OVERRIDE;
78 virtual void OnChannelError() OVERRIDE;
79 virtual bool IsPlugin() const;
80
81 private:
82 typedef std::map<PP_Instance, base::WeakPtr<RenderViewImpl> > InstanceMap;
83 typedef std::map<int, int> RoutingIDToInstanceMap;
84
85 void OnSupportsInterface(const std::string& interface_name, bool* result);
86 void OnSetPreferences(const ppapi::Preferences& prefs);
87 void OnReserveInstanceId(PP_Instance instance, bool* usable);
88 void OnDidCreate(PP_Instance instance,
89 const std::vector<std::string>& argn,
90 const std::vector<std::string>& argv,
91 PP_Bool* result);
92 void OnDidDestroy(PP_Instance instance);
93 void OnDidChangeView(PP_Instance instance,
94 const ppapi::ViewData& new_data,
95 PP_Bool flash_fullscreen);
96 void OnDidChangeFocus(PP_Instance instance, PP_Bool has_focus);
97 void OnGetInstanceObject(PP_Instance instance,
98 ppapi::proxy::SerializedVarReturnValue result);
99
100 void OnHandleMessage(PP_Instance instance,
101 ppapi::proxy::SerializedVarReceiveInput data);
102
103 void OnHandleFilteredInputEvent(PP_Instance instance,
104 const ppapi::InputEventData& data,
105 PP_Bool* result);
106
107 void OnSwapBuffersACK(const ppapi::HostResource& context,
108 int32_t pp_error);
109
110 void OnContextLost(PP_Instance instance);
111
112 base::WeakPtr<RenderViewImpl> render_view_;
113 BrowserPluginChannelManager* channel_manager_;
114 std::string embedder_channel_name_;
115 PepperProxyChannelDelegateImpl delegate_;
116
117 InstanceMap render_view_instances_;
118 RoutingIDToInstanceMap routing_id_instance_map_;
119
120 DISALLOW_COPY_AND_ASSIGN(GuestToEmbedderChannel);
121 };
122
123 } // namespace content
124
125 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698