IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / frame_host / cross_process_frame_connector.cc
blobef150be5674dbfcdea9b27385d64b1352b214fc8
1 // Copyright 2014 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.
5 #include "content/browser/frame_host/cross_process_frame_connector.h"
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"
13 namespace content {
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);
22 CrossProcessFrameConnector::~CrossProcessFrameConnector() {
23 if (view_)
24 view_->set_cross_process_child_frame(NULL);
27 bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) {
28 bool handled = true;
29 bool msg_is_ok = true;
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()
36 return handled;
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);
45 view_ = view;
47 // Attach ourselves to the new view.
48 if (view_)
49 view_->set_cross_process_child_frame(this);
52 void CrossProcessFrameConnector::ChildFrameBuffersSwapped(
53 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& gpu_params,
54 int gpu_host_id) {
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;
62 frame_proxy_in_parent_renderer_->Send(
63 new FrameMsg_BuffersSwapped(
64 frame_proxy_in_parent_renderer_->routing_id(),
65 params));
68 void CrossProcessFrameConnector::ChildFrameCompositorFrameSwapped(
69 uint32 output_surface_id,
70 scoped_ptr<cc::CompositorFrame> frame) {
73 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() {
74 return child_frame_rect_;
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);
86 // TODO(kenrb): Special case stuff for Win + Mac.
89 } // namespace content