| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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/browser/frame_host/cross_process_frame_connector.h" |
| 6 |
| 7 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 8 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 10 #include "content/common/frame_messages.h" |
| 11 #include "content/common/gpu/gpu_messages.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 CrossProcessFrameConnector::CrossProcessFrameConnector( |
| 16 RenderFrameHostImpl* frame_proxy_in_parent_renderer) |
| 17 : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), |
| 18 view_(NULL) { |
| 19 frame_proxy_in_parent_renderer->set_cross_process_frame_connector(this); |
| 20 } |
| 21 |
| 22 CrossProcessFrameConnector::~CrossProcessFrameConnector() { |
| 23 if (view_) |
| 24 view_->set_cross_process_child_frame(NULL); |
| 25 } |
| 26 |
| 27 bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) { |
| 28 bool handled = true; |
| 29 bool msg_is_ok = true; |
| 30 |
| 31 IPC_BEGIN_MESSAGE_MAP_EX(CrossProcessFrameConnector, msg, msg_is_ok) |
| 32 IPC_MESSAGE_HANDLER(FrameHostMsg_BuffersSwappedACK, OnBuffersSwappedACK) |
| 33 IPC_MESSAGE_UNHANDLED(handled = false) |
| 34 IPC_END_MESSAGE_MAP_EX() |
| 35 |
| 36 return handled; |
| 37 } |
| 38 |
| 39 void CrossProcessFrameConnector::SetView( |
| 40 RenderWidgetHostViewChildFrame* view) { |
| 41 // Detach ourselves from the previous |view_|. |
| 42 if (view_) |
| 43 view_->set_cross_process_child_frame(NULL); |
| 44 |
| 45 view_ = view; |
| 46 |
| 47 // Attach ourselves to the new view. |
| 48 if (view_) |
| 49 view_->set_cross_process_child_frame(this); |
| 50 } |
| 51 |
| 52 void CrossProcessFrameConnector::ChildFrameBuffersSwapped( |
| 53 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& gpu_params, |
| 54 int gpu_host_id) { |
| 55 |
| 56 FrameMsg_BuffersSwapped_Params params; |
| 57 params.size = gpu_params.size; |
| 58 params.mailbox_name = gpu_params.mailbox_name; |
| 59 params.gpu_route_id = gpu_params.route_id; |
| 60 params.gpu_host_id = gpu_host_id; |
| 61 |
| 62 frame_proxy_in_parent_renderer_->Send( |
| 63 new FrameMsg_BuffersSwapped( |
| 64 frame_proxy_in_parent_renderer_->routing_id(), |
| 65 params)); |
| 66 } |
| 67 |
| 68 void CrossProcessFrameConnector::ChildFrameCompositorFrameSwapped( |
| 69 uint32 output_surface_id, |
| 70 scoped_ptr<cc::CompositorFrame> frame) { |
| 71 } |
| 72 |
| 73 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { |
| 74 return child_frame_rect_; |
| 75 } |
| 76 |
| 77 void CrossProcessFrameConnector::OnBuffersSwappedACK( |
| 78 const FrameHostMsg_BuffersSwappedACK_Params& params) { |
| 79 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 80 ack_params.mailbox_name = params.mailbox_name; |
| 81 ack_params.sync_point = params.sync_point; |
| 82 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.gpu_route_id, |
| 83 params.gpu_host_id, |
| 84 ack_params); |
| 85 |
| 86 // TODO(kenrb): Special case stuff for Win + Mac. |
| 87 } |
| 88 |
| 89 } // namespace content |
| OLD | NEW |