| 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 child_frame_widget_(NULL) { |
| 19 frame_proxy_in_parent_renderer->SetCrossProcessFrameConnector(this); |
| 20 } |
| 21 |
| 22 CrossProcessFrameConnector::~CrossProcessFrameConnector() { |
| 23 if (child_frame_widget_ && child_frame_widget_->GetView()) |
| 24 static_cast<RenderWidgetHostViewChildFrame*>( |
| 25 child_frame_widget_->GetView())->SetCrossProcessFrameConnector(NULL); |
| 26 } |
| 27 |
| 28 // static |
| 29 CrossProcessFrameConnector* |
| 30 CrossProcessFrameConnector::CreateCrossProcessFrameConnector( |
| 31 RenderFrameHostImpl* frame_proxy_in_parent_renderer) { |
| 32 return new CrossProcessFrameConnector(frame_proxy_in_parent_renderer); |
| 33 } |
| 34 |
| 35 bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) { |
| 36 bool handled = true; |
| 37 bool msg_is_ok = true; |
| 38 |
| 39 IPC_BEGIN_MESSAGE_MAP_EX(CrossProcessFrameConnector, msg, msg_is_ok) |
| 40 IPC_MESSAGE_HANDLER(FrameHostMsg_BuffersSwappedACK, OnBuffersSwappedACK) |
| 41 IPC_MESSAGE_UNHANDLED(handled = false) |
| 42 IPC_END_MESSAGE_MAP_EX() |
| 43 |
| 44 return handled; |
| 45 } |
| 46 |
| 47 void CrossProcessFrameConnector::SetChildFrameView( |
| 48 RenderWidgetHostViewChildFrame* child_frame_view) { |
| 49 // Detach ourselves from the previous |child_frame_view_|. |
| 50 if (child_frame_view_) |
| 51 child_frame_view_->SetCrossProcessFrameConnector(NULL); |
| 52 |
| 53 // Attach ourselves to the new view. |
| 54 if (child_frame_view) |
| 55 child_frame_view->SetCrossProcessFrameConnector(this); |
| 56 |
| 57 child_frame_view_ = child_frame_view; |
| 58 } |
| 59 |
| 60 void CrossProcessFrameConnector::ChildFrameBuffersSwapped( |
| 61 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 62 int gpu_host_id) { |
| 63 frame_proxy_in_parent_renderer_->Send( |
| 64 new FrameMsg_ChildFrameBuffersSwapped( |
| 65 frame_proxy_in_parent_renderer_->routing_id(), |
| 66 params.size, |
| 67 params.mailbox_name, |
| 68 params.route_id, |
| 69 gpu_host_id)); |
| 70 } |
| 71 |
| 72 void CrossProcessFrameConnector::ChildFrameCompositorFrameSwapped( |
| 73 uint32 output_surface_id, |
| 74 scoped_ptr<cc::CompositorFrame> frame) { |
| 75 } |
| 76 |
| 77 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { |
| 78 return child_frame_rect_; |
| 79 } |
| 80 |
| 81 void CrossProcessFrameConnector::OnBuffersSwappedACK(std::string mailbox_name, |
| 82 int route_id, |
| 83 int gpu_host_id, |
| 84 uint32 sync_point) { |
| 85 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 86 ack_params.mailbox_name = mailbox_name; |
| 87 ack_params.sync_point = sync_point; |
| 88 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 89 gpu_host_id, |
| 90 ack_params); |
| 91 |
| 92 // TODO(kenrb): Special case stuff for Win + Mac. |
| 93 } |
| 94 |
| 95 void CrossProcessFrameConnector::Destroy() { |
| 96 if (child_frame_widget_ && child_frame_widget_->GetView()) |
| 97 static_cast<RenderWidgetHostViewChildFrame*>(child_frame_widget_-> |
| 98 GetView())->SetCrossProcessFrameConnector(NULL); |
| 99 delete this; |
| 100 } |
| 101 |
| 102 } // namespace content |
| OLD | NEW |