Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #include "content/renderer/browser_plugin/guest_render_view_observer.h" | |
| 6 | |
| 7 #include "base/process_util.h" | |
| 8 #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.
| |
| 9 #include "content/common/browser_plugin_messages.h" | |
| 10 #include "content/common/view_messages.h" | |
| 11 #include "content/public/renderer/render_view.h" | |
| 12 #include "content/renderer/browser_plugin/browser_plugin_placeholder.h" | |
| 13 #include "content/renderer/render_view_impl.h" | |
| 14 #include "ppapi/proxy/ppapi_messages.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
| 16 | |
| 17 using WebKit::WebGraphicsContext3D; | |
| 18 | |
| 19 GuestRenderViewObserver::GuestRenderViewObserver( | |
| 20 content::RenderView* render_view) | |
| 21 : RenderViewObserver(render_view), | |
| 22 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.
| |
| 23 | |
| 24 Send(new BrowserPluginHostMsg_GuestReady(render_view->GetRoutingID())); | |
| 25 } | |
| 26 | |
| 27 void GuestRenderViewObserver::IssueSwapBuffers() { | |
| 28 guest_to_host_channel_.IssueSwapBuffers(); | |
| 29 } | |
| 30 | |
| 31 bool GuestRenderViewObserver::OnMessageReceived(const IPC::Message& message) { | |
| 32 bool handled = true; | |
| 33 IPC_BEGIN_MESSAGE_MAP(GuestRenderViewObserver, message) | |
| 34 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CreateChannel, OnCreateChannel) | |
| 35 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestReady_ACK, OnGuestReady) | |
| 36 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 37 IPC_END_MESSAGE_MAP() | |
| 38 | |
| 39 return handled; | |
| 40 } | |
| 41 | |
| 42 void GuestRenderViewObserver::OnCreateChannel( | |
| 43 base::ProcessHandle host_process_handle, | |
| 44 int renderer_id) { | |
| 45 IPC::ChannelHandle plugin_handle; | |
| 46 plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(), | |
| 47 renderer_id); | |
| 48 bool success = guest_to_host_channel_.InitChannel(plugin_handle); | |
| 49 #if defined(OS_POSIX) | |
| 50 // On POSIX, transfer ownership of the renderer-side (client) FD. | |
| 51 // This ensures this process will be notified when it is closed even if a | |
| 52 // connection is not established. | |
| 53 plugin_handle.socket = | |
| 54 base::FileDescriptor(guest_to_host_channel_.TakeRendererFD(), true); | |
| 55 // Check the validity of fd for bug investigation. Remove after fixed. | |
| 56 // See for details: crbug.com/103957. | |
| 57 CHECK_NE(-1, plugin_handle.socket.fd); | |
| 58 if (plugin_handle.socket.fd == -1) | |
| 59 success = false; | |
| 60 #endif | |
| 61 BrowserPluginHostMsg_ChannelCreated* msg; | |
| 62 if (success) | |
| 63 msg = new BrowserPluginHostMsg_ChannelCreated(plugin_handle); | |
| 64 else | |
| 65 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.
| |
| 66 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.
| |
| 67 Send(msg); | |
| 68 } | |
| 69 | |
| 70 void GuestRenderViewObserver::OnGuestReady( | |
| 71 int instance_id, | |
| 72 base::ProcessHandle process_handle, | |
| 73 const IPC::ChannelHandle& channel_handle) { | |
| 74 BrowserPluginPlaceholder* placeholder = | |
| 75 BrowserPluginPlaceholder::FromID(instance_id); | |
| 76 if (placeholder) | |
| 77 placeholder->GuestReady(process_handle, channel_handle); | |
|
jam
2012/04/06 21:05:23
nit:spacing
Fady Samuel
2012/04/06 22:46:32
Done.
| |
| 78 } | |
| 79 | |
| 80 WebGraphicsContext3DCommandBufferImpl* | |
| 81 GuestRenderViewObserver::GetWebGraphicsContext3D( | |
| 82 const WebKit::WebGraphicsContext3D::Attributes& attributes) { | |
| 83 return guest_to_host_channel_.GetWebGraphicsContext3D(attributes); | |
| 84 } | |
| OLD | NEW |