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

Unified Diff: content/renderer/browser_plugin/guest_render_view_observer.cc

Issue 9968097: Browser Plugin: Renderer-side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed unnecessary include and forward declaration. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/guest_render_view_observer.cc
diff --git a/content/renderer/browser_plugin/guest_render_view_observer.cc b/content/renderer/browser_plugin/guest_render_view_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8afa8b570e41f774fb2dfa39fce5254ebeb6bd9e
--- /dev/null
+++ b/content/renderer/browser_plugin/guest_render_view_observer.cc
@@ -0,0 +1,84 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/browser_plugin/guest_render_view_observer.h"
+
+#include "base/process_util.h"
+#include "content/common/child_process.h"
jam 2012/04/06 21:05:23 are you sure you need this?
Fady Samuel 2012/04/06 22:46:32 Done.
+#include "content/common/browser_plugin_messages.h"
+#include "content/common/view_messages.h"
+#include "content/public/renderer/render_view.h"
+#include "content/renderer/browser_plugin/browser_plugin_placeholder.h"
+#include "content/renderer/render_view_impl.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+
+using WebKit::WebGraphicsContext3D;
+
+GuestRenderViewObserver::GuestRenderViewObserver(
+ content::RenderView* render_view)
+ : RenderViewObserver(render_view),
+ guest_to_host_channel_(this, render_view->GetWebView()) {
jam 2012/04/06 21:05:23 nit: spacing
Fady Samuel 2012/04/06 22:46:32 Done.
+
+ Send(new BrowserPluginHostMsg_GuestReady(render_view->GetRoutingID()));
+}
+
+void GuestRenderViewObserver::IssueSwapBuffers() {
+ guest_to_host_channel_.IssueSwapBuffers();
+}
+
+bool GuestRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(GuestRenderViewObserver, message)
+ IPC_MESSAGE_HANDLER(BrowserPluginMsg_CreateChannel, OnCreateChannel)
+ IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestReady_ACK, OnGuestReady)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+void GuestRenderViewObserver::OnCreateChannel(
+ base::ProcessHandle host_process_handle,
+ int renderer_id) {
+ IPC::ChannelHandle plugin_handle;
+ plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(),
+ renderer_id);
+ bool success = guest_to_host_channel_.InitChannel(plugin_handle);
+#if defined(OS_POSIX)
+ // On POSIX, transfer ownership of the renderer-side (client) FD.
+ // This ensures this process will be notified when it is closed even if a
+ // connection is not established.
+ plugin_handle.socket =
+ base::FileDescriptor(guest_to_host_channel_.TakeRendererFD(), true);
+ // Check the validity of fd for bug investigation. Remove after fixed.
+ // See for details: crbug.com/103957.
+ CHECK_NE(-1, plugin_handle.socket.fd);
+ if (plugin_handle.socket.fd == -1)
+ success = false;
+#endif
+ BrowserPluginHostMsg_ChannelCreated* msg;
+ if (success)
+ msg = new BrowserPluginHostMsg_ChannelCreated(plugin_handle);
+ else
+ msg = new BrowserPluginHostMsg_ChannelCreated(IPC::ChannelHandle());
jam 2012/04/06 21:05:23 nit: much simpler to just do Send(new FooMsg(succe
Fady Samuel 2012/04/06 22:46:32 Done.
+ msg->set_routing_id(routing_id());
jam 2012/04/06 21:05:23 if this is a routed message, it should be declared
Fady Samuel 2012/04/06 22:46:32 Remnant of earlier reuse of ppapi messages. Fixed.
+ Send(msg);
+}
+
+void GuestRenderViewObserver::OnGuestReady(
+ int instance_id,
+ base::ProcessHandle process_handle,
+ const IPC::ChannelHandle& channel_handle) {
+ BrowserPluginPlaceholder* placeholder =
+ BrowserPluginPlaceholder::FromID(instance_id);
+ if (placeholder)
+ placeholder->GuestReady(process_handle, channel_handle);
jam 2012/04/06 21:05:23 nit:spacing
Fady Samuel 2012/04/06 22:46:32 Done.
+}
+
+WebGraphicsContext3DCommandBufferImpl*
+GuestRenderViewObserver::GetWebGraphicsContext3D(
+ const WebKit::WebGraphicsContext3D::Attributes& attributes) {
+ return guest_to_host_channel_.GetWebGraphicsContext3D(attributes);
+}

Powered by Google App Engine
This is Rietveld 408576698