diff options
26 files changed, 1163 insertions, 260 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index 0e6ba06..716c2b7 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -507,8 +507,8 @@ bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, OnSwapBuffersACK) - IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameACK, - OnCompositorFrameACK) + IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, + OnCompositorFrameSwappedACK) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, OnCopyFromCompositingSurfaceAck) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, @@ -1142,7 +1142,7 @@ bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( const IPC::Message& message) { switch (message.type()) { case BrowserPluginHostMsg_BuffersSwappedACK::ID: - case BrowserPluginHostMsg_CompositorFrameACK::ID: + case BrowserPluginHostMsg_CompositorFrameSwappedACK::ID: case BrowserPluginHostMsg_CopyFromCompositingSurfaceAck::ID: case BrowserPluginHostMsg_DragStatusUpdate::ID: case BrowserPluginHostMsg_ExecuteEditCommand::ID: @@ -1256,16 +1256,13 @@ void BrowserPluginGuest::Attach( RecordAction(UserMetricsAction("BrowserPlugin.Guest.Attached")); } -void BrowserPluginGuest::OnCompositorFrameACK( +void BrowserPluginGuest::OnCompositorFrameSwappedACK( int instance_id, - int route_id, - uint32 output_surface_id, - int renderer_host_id, - const cc::CompositorFrameAck& ack) { - RenderWidgetHostImpl::SendSwapCompositorFrameAck(route_id, - output_surface_id, - renderer_host_id, - ack); + const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { + RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, + params.output_surface_id, + params.producing_host_id, + params.ack); } void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, @@ -1575,12 +1572,11 @@ void BrowserPluginGuest::OnSetVisibility(int instance_id, bool visible) { GetWebContents()->WasHidden(); } -void BrowserPluginGuest::OnSwapBuffersACK(int instance_id, - int route_id, - int gpu_host_id, - const std::string& mailbox_name, - uint32 sync_point) { - AcknowledgeBufferPresent(route_id, gpu_host_id, mailbox_name, sync_point); +void BrowserPluginGuest::OnSwapBuffersACK( + int instance_id, + const FrameHostMsg_BuffersSwappedACK_Params& params) { + AcknowledgeBufferPresent(params.gpu_route_id, params.gpu_host_id, + params.mailbox_name, params.sync_point); // This is only relevant on MACOSX and WIN when threaded compositing // is not enabled. In threaded mode, above ACK is sufficient. diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h index 46c95a4..84675b5 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.h +++ b/content/browser/browser_plugin/browser_plugin_guest.h @@ -45,6 +45,8 @@ struct BrowserPluginHostMsg_AutoSize_Params; struct BrowserPluginHostMsg_Attach_Params; struct BrowserPluginHostMsg_ResizeGuest_Params; +struct FrameHostMsg_BuffersSwappedACK_Params; +struct FrameHostMsg_CompositorFrameSwappedACK_Params; struct ViewHostMsg_CreateWindow_Params; #if defined(OS_MACOSX) struct ViewHostMsg_ShowPopup_Params; @@ -382,11 +384,9 @@ class CONTENT_EXPORT BrowserPluginGuest // Message handlers for messages from embedder. - void OnCompositorFrameACK(int instance_id, - int route_id, - uint32 output_surface_id, - int renderer_host_id, - const cc::CompositorFrameAck& ack); + void OnCompositorFrameSwappedACK( + int instance_id, + const FrameHostMsg_CompositorFrameSwappedACK_Params& params); void OnCopyFromCompositingSurfaceAck(int instance_id, int request_id, const SkBitmap& bitmap); @@ -457,10 +457,7 @@ class CONTENT_EXPORT BrowserPluginGuest void OnSetVisibility(int instance_id, bool visible); // Message from embedder acknowledging last HW buffer. void OnSwapBuffersACK(int instance_id, - int route_id, - int gpu_host_id, - const std::string& mailbox_name, - uint32 sync_point); + const FrameHostMsg_BuffersSwappedACK_Params& params); void OnUnlockMouse(); void OnUnlockMouseAck(int instance_id); void OnUpdateGeometry(int instance_id, const gfx::Rect& view_rect); diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc index d16d11a..8fb51b6 100644 --- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc +++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc @@ -217,14 +217,11 @@ SiteInstance* BrowserPluginGuestManager::GetGuestSiteInstance( // otherwise the ACK is handled by the guest. void BrowserPluginGuestManager::OnUnhandledSwapBuffersACK( int instance_id, - int route_id, - int gpu_host_id, - const std::string& mailbox_name, - uint32 sync_point) { - BrowserPluginGuest::AcknowledgeBufferPresent(route_id, - gpu_host_id, - mailbox_name, - sync_point); + const FrameHostMsg_BuffersSwappedACK_Params& params) { + BrowserPluginGuest::AcknowledgeBufferPresent(params.gpu_route_id, + params.gpu_host_id, + params.mailbox_name, + params.sync_point); } void BrowserPluginGuestManager::DidSendScreenRects( diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.h b/content/browser/browser_plugin/browser_plugin_guest_manager.h index 1ce9a9f..f0bee02 100644 --- a/content/browser/browser_plugin/browser_plugin_guest_manager.h +++ b/content/browser/browser_plugin/browser_plugin_guest_manager.h @@ -17,6 +17,7 @@ struct BrowserPluginHostMsg_Attach_Params; struct BrowserPluginHostMsg_ResizeGuest_Params; +struct FrameHostMsg_BuffersSwappedACK_Params; class GURL; namespace gfx { @@ -117,11 +118,9 @@ class CONTENT_EXPORT BrowserPluginGuestManager : SiteInstance* GetGuestSiteInstance(const GURL& guest_site); // Message handlers. - void OnUnhandledSwapBuffersACK(int instance_id, - int route_id, - int gpu_host_id, - const std::string& mailbox_name, - uint32 sync_point); + void OnUnhandledSwapBuffersACK( + int instance_id, + const FrameHostMsg_BuffersSwappedACK_Params& params); // Static factory instance (always NULL outside of tests). static BrowserPluginHostFactory* factory_; diff --git a/content/browser/frame_host/cross_process_frame_connector.cc b/content/browser/frame_host/cross_process_frame_connector.cc new file mode 100644 index 0000000..ef150be --- /dev/null +++ b/content/browser/frame_host/cross_process_frame_connector.cc @@ -0,0 +1,89 @@ +// Copyright 2014 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/browser/frame_host/cross_process_frame_connector.h" + +#include "content/browser/frame_host/render_frame_host_impl.h" +#include "content/browser/frame_host/render_widget_host_view_child_frame.h" +#include "content/browser/renderer_host/render_widget_host_impl.h" +#include "content/common/frame_messages.h" +#include "content/common/gpu/gpu_messages.h" + +namespace content { + +CrossProcessFrameConnector::CrossProcessFrameConnector( + RenderFrameHostImpl* frame_proxy_in_parent_renderer) + : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), + view_(NULL) { + frame_proxy_in_parent_renderer->set_cross_process_frame_connector(this); +} + +CrossProcessFrameConnector::~CrossProcessFrameConnector() { + if (view_) + view_->set_cross_process_child_frame(NULL); +} + +bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) { + bool handled = true; + bool msg_is_ok = true; + + IPC_BEGIN_MESSAGE_MAP_EX(CrossProcessFrameConnector, msg, msg_is_ok) + IPC_MESSAGE_HANDLER(FrameHostMsg_BuffersSwappedACK, OnBuffersSwappedACK) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP_EX() + + return handled; +} + +void CrossProcessFrameConnector::SetView( + RenderWidgetHostViewChildFrame* view) { + // Detach ourselves from the previous |view_|. + if (view_) + view_->set_cross_process_child_frame(NULL); + + view_ = view; + + // Attach ourselves to the new view. + if (view_) + view_->set_cross_process_child_frame(this); +} + +void CrossProcessFrameConnector::ChildFrameBuffersSwapped( + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& gpu_params, + int gpu_host_id) { + + FrameMsg_BuffersSwapped_Params params; + params.size = gpu_params.size; + params.mailbox_name = gpu_params.mailbox_name; + params.gpu_route_id = gpu_params.route_id; + params.gpu_host_id = gpu_host_id; + + frame_proxy_in_parent_renderer_->Send( + new FrameMsg_BuffersSwapped( + frame_proxy_in_parent_renderer_->routing_id(), + params)); +} + +void CrossProcessFrameConnector::ChildFrameCompositorFrameSwapped( + uint32 output_surface_id, + scoped_ptr<cc::CompositorFrame> frame) { +} + +gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { + return child_frame_rect_; +} + +void CrossProcessFrameConnector::OnBuffersSwappedACK( + const FrameHostMsg_BuffersSwappedACK_Params& params) { + AcceleratedSurfaceMsg_BufferPresented_Params ack_params; + ack_params.mailbox_name = params.mailbox_name; + ack_params.sync_point = params.sync_point; + RenderWidgetHostImpl::AcknowledgeBufferPresent(params.gpu_route_id, + params.gpu_host_id, + ack_params); + + // TODO(kenrb): Special case stuff for Win + Mac. +} + +} // namespace content diff --git a/content/browser/frame_host/cross_process_frame_connector.h b/content/browser/frame_host/cross_process_frame_connector.h new file mode 100644 index 0000000..e107acc --- /dev/null +++ b/content/browser/frame_host/cross_process_frame_connector.h @@ -0,0 +1,103 @@ +// Copyright 2014 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. + +#ifndef CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_ +#define CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_ + +#include "cc/output/compositor_frame.h" +#include "ui/gfx/rect.h" + +namespace IPC { +class Message; +} + +struct FrameHostMsg_BuffersSwappedACK_Params; +struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; + +namespace content { +class RenderFrameHostImpl; +class RenderWidgetHostImpl; +class RenderWidgetHostViewChildFrame; + +// CrossProcessFrameConnector provides the platform view abstraction for +// RenderWidgetHostViewChildFrame allowing RWHVChildFrame to remain ignorant +// of RenderFrameHost. +// +// The RenderWidgetHostView of an out-of-process child frame needs to +// communicate with the swapped out RenderFrameHost representing this frame +// in the process of the parent frame. For example, assume you have this page: +// +// ----------------- +// | frame 1 | +// | ----------- | +// | | frame 2 | | +// | ----------- | +// ----------------- +// +// If frames 1 and 2 are in process A and B, there are 4 RenderFrameHosts: +// A1 - RFH for frame 1 in process A +// B1 - Swapped out RFH for frame 1 in process B +// A2 - Swapped out RFH for frame 2 in process A +// B2 - RFH for frame 2 in process B +// +// B2, having a parent frame in a diferent process, will have a +// RenderWidgetHostViewChildFrame. This RenderWidgetHostViewChildFrame needs +// to communicate with A2 so that the painting logic in process A can +// composite B2's data with A1's. CrossProcessFrameConnector bridges between +// B2's RenderWidgetHostViewChildFrame and A2 to allow for this communication. +// (Note: B1 is only mentioned for completeness. It is not needed in this +// example.) +// +// CrossProcessFrameConnector objects are owned by the child frame's +// RenderFrameHostManager. When a child frame swaps, SetChildFrameView() is +// called to update to the new view. +// +// TODO(kenrb): Double-check this comment's accuracy. +class CrossProcessFrameConnector { + public: + // |frame_proxy_in_parent_renderer| corresponds to A2 in the example above. + explicit CrossProcessFrameConnector( + RenderFrameHostImpl* frame_proxy_in_parent_renderer); + virtual ~CrossProcessFrameConnector(); + + bool OnMessageReceived(const IPC::Message &msg); + + // |view| corresponds to B2's RenderWidgetHostViewChildFrame in the example + // above. + void SetView(RenderWidgetHostViewChildFrame* view); + + // 'Platform' functionality exposed to RenderWidgetHostViewChildFrame. + // These methods can forward messages to the child frame proxy in the parent + // frame renderer or attempt to handle them within the browser process. + void ChildFrameBuffersSwapped( + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, + int gpu_host_id); + + void ChildFrameCompositorFrameSwapped( + uint32 output_surface_id, + scoped_ptr<cc::CompositorFrame> frame); + + gfx::Rect ChildFrameRect(); + + private: + // Handlers for messages received from the parent frame. + void OnBuffersSwappedACK( + const FrameHostMsg_BuffersSwappedACK_Params& params); + + // The RenderFrameHost that routes messages to the parent frame's renderer + // process. + // TODO(kenrb): The type becomes RenderFrameProxyHost when that class comes + // to exist. + RenderFrameHostImpl* frame_proxy_in_parent_renderer_; + + // The RenderWidgetHostView for the frame. Initially NULL. + RenderWidgetHostViewChildFrame* view_; + + gfx::Rect child_frame_rect_; +}; + +} // namespace content + +#endif // CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_ + diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index 0d16779..620d87d 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -6,6 +6,7 @@ #include "base/containers/hash_tables.h" #include "base/lazy_instance.h" +#include "content/browser/frame_host/cross_process_frame_connector.h" #include "content/browser/frame_host/frame_tree.h" #include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/frame_host/navigator.h" @@ -51,6 +52,7 @@ RenderFrameHostImpl::RenderFrameHostImpl( bool is_swapped_out) : render_view_host_(render_view_host), delegate_(delegate), + cross_process_frame_connector_(NULL), frame_tree_(frame_tree), frame_tree_node_(frame_tree_node), routing_id_(routing_id), diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index 155b427..ebe50a6 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -19,6 +19,7 @@ class FilePath; namespace content { +class CrossProcessFrameConnector; class FrameTree; class FrameTreeNode; class RenderFrameHostDelegate; @@ -54,6 +55,18 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { RenderViewHostImpl* render_view_host() { return render_view_host_; } RenderFrameHostDelegate* delegate() { return delegate_; } + // This function is called when this is a swapped out RenderFrameHost that + // lives in the same process as the parent frame. The + // |cross_process_frame_connector| allows the non-swapped-out + // RenderFrameHost for a frame to communicate with the parent process + // so that it may composite drawing data. + // + // Ownership is not transfered. + void set_cross_process_frame_connector( + CrossProcessFrameConnector* cross_process_frame_connector) { + cross_process_frame_connector_ = cross_process_frame_connector; + } + protected: friend class RenderFrameHostFactory; @@ -89,6 +102,18 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { RenderFrameHostDelegate* delegate_; + // |cross_process_frame_connector_| passes messages from an out-of-process + // child frame to the parent process for compositing. + // + // This is only non-NULL when this is the swapped out RenderFrameHost in + // the same site instance as this frame's parent. + // + // See the class comment above CrossProcessFrameConnector for more + // information. + // + // This will move to RenderFrameProxyHost when that class is created. + CrossProcessFrameConnector* cross_process_frame_connector_; + // Reference to the whole frame tree that this RenderFrameHost belongs too. // Allows this RenderFrameHost to add and remove nodes in response to // messages from the renderer requesting DOM manipulation. diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc new file mode 100644 index 0000000..832f0c4 --- /dev/null +++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc @@ -0,0 +1,373 @@ +// Copyright 2014 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/browser/frame_host/render_widget_host_view_child_frame.h" + +#include "content/browser/frame_host/cross_process_frame_connector.h" +#include "content/browser/renderer_host/render_widget_host_impl.h" +#include "content/common/gpu/gpu_messages.h" +#include "content/common/view_messages.h" +#include "content/public/browser/render_process_host.h" + +namespace content { + +RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( + RenderWidgetHost* widget_host) + : host_(RenderWidgetHostImpl::From(widget_host)), + frame_connector_(NULL) { + host_->SetView(this); +} + +RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { +} + +void RenderWidgetHostViewChildFrame::InitAsChild( + gfx::NativeView parent_view) { + NOTREACHED(); +} + +RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const { + return host_; +} + +void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size& size) { + size_ = size; + host_->WasResized(); +} + +void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect& rect) { + SetSize(rect.size()); +} + +void RenderWidgetHostViewChildFrame::Focus() { +} + +bool RenderWidgetHostViewChildFrame::HasFocus() const { + return false; +} + +bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const { + NOTIMPLEMENTED(); + return false; +} + +void RenderWidgetHostViewChildFrame::Show() { + WasShown(); +} + +void RenderWidgetHostViewChildFrame::Hide() { + WasHidden(); +} + +bool RenderWidgetHostViewChildFrame::IsShowing() { + return !host_->is_hidden(); +} + +gfx::Rect RenderWidgetHostViewChildFrame::GetViewBounds() const { + gfx::Rect rect; + if (frame_connector_) + rect = frame_connector_->ChildFrameRect(); + rect.set_width(size_.width()); + rect.set_height(size_.height()); + return rect; +} + +gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const { + NOTREACHED(); + return NULL; +} + +gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const { + NOTREACHED(); + return 0; +} + +gfx::NativeViewAccessible +RenderWidgetHostViewChildFrame::GetNativeViewAccessible() { + NOTREACHED(); + return NULL; +} + +void RenderWidgetHostViewChildFrame::SetBackground( + const SkBitmap& background) { +} + +gfx::Size RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const { + return size_; +} + +void RenderWidgetHostViewChildFrame::InitAsPopup( + RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) { + NOTREACHED(); +} + +void RenderWidgetHostViewChildFrame::InitAsFullscreen( + RenderWidgetHostView* reference_host_view) { + NOTREACHED(); +} + +void RenderWidgetHostViewChildFrame::ImeCancelComposition() { + NOTREACHED(); +} + +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) +void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged( + const gfx::Range& range, + const std::vector<gfx::Rect>& character_bounds) { + NOTREACHED(); +} +#endif + +void RenderWidgetHostViewChildFrame::DidUpdateBackingStore( + const gfx::Rect& scroll_rect, + const gfx::Vector2d& scroll_delta, + const std::vector<gfx::Rect>& copy_rects, + const std::vector<ui::LatencyInfo>& latency_info) { + NOTREACHED(); +} + +void RenderWidgetHostViewChildFrame::WasShown() { + if (!host_->is_hidden()) + return; + host_->WasShown(); +} + +void RenderWidgetHostViewChildFrame::WasHidden() { + if (host_->is_hidden()) + return; + host_->WasHidden(); +} + +void RenderWidgetHostViewChildFrame::MovePluginWindows( + const gfx::Vector2d& scroll_offset, + const std::vector<WebPluginGeometry>& moves) { +} + +void RenderWidgetHostViewChildFrame::Blur() { +} + +void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor& cursor) { +} + +void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading) { + NOTREACHED(); +} + +void RenderWidgetHostViewChildFrame::TextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { + NOTREACHED(); +} + +void RenderWidgetHostViewChildFrame::RenderProcessGone( + base::TerminationStatus status, + int error_code) { +} + +void RenderWidgetHostViewChildFrame::Destroy() { + // TODO(ajwong): Why did Ken destroy the |frame_connector_| here? + frame_connector_ = NULL; + + host_->SetView(NULL); + host_ = NULL; + base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); +} + +void RenderWidgetHostViewChildFrame::SetTooltipText( + const base::string16& tooltip_text) { +} + +void RenderWidgetHostViewChildFrame::SelectionChanged( + const base::string16& text, + size_t offset, + const gfx::Range& range) { +} + +void RenderWidgetHostViewChildFrame::SelectionBoundsChanged( + const ViewHostMsg_SelectionBounds_Params& params) { +} + +void RenderWidgetHostViewChildFrame::ScrollOffsetChanged() { +} + +void RenderWidgetHostViewChildFrame::OnAcceleratedCompositingStateChange() { +} + +void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id, + int route_id) { +} + +void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped( + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, + int gpu_host_id) { + if (frame_connector_) + frame_connector_->ChildFrameBuffersSwapped(params, gpu_host_id); +} + +void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { +} + +void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame( + uint32 output_surface_id, + scoped_ptr<cc::CompositorFrame> frame) { + if (frame_connector_) + frame_connector_->ChildFrameCompositorFrameSwapped( + output_surface_id, frame.Pass()); +} + +void RenderWidgetHostViewChildFrame::GetScreenInfo( + blink::WebScreenInfo* results) { +} + +gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() { + // We do not have any root window specific parts in this view. + return GetViewBounds(); +} + +#if defined(OS_WIN) || defined(USE_AURA) +void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent( + const TouchEventWithLatencyInfo& touch, + InputEventAckState ack_result) { +} +#endif // defined(OS_WIN) || defined(USE_AURA) + +bool RenderWidgetHostViewChildFrame::LockMouse() { + return false; +} + +void RenderWidgetHostViewChildFrame::UnlockMouse() { +} + +#if defined(OS_MACOSX) +void RenderWidgetHostViewChildFrame::SetActive(bool active) { +} + +void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag) { +} + +void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) { +} + +void RenderWidgetHostViewChildFrame::WindowFrameChanged() { +} + +void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() { +} + +bool RenderWidgetHostViewChildFrame::SupportsSpeech() const { + return false; +} + +void RenderWidgetHostViewChildFrame::SpeakSelection() { +} + +bool RenderWidgetHostViewChildFrame::IsSpeaking() const { + return false; +} + +void RenderWidgetHostViewChildFrame::StopSpeaking() { +} + +bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme( + const NativeWebKeyboardEvent& event) { + return false; +} +#endif // defined(OS_MACOSX) + +#if defined(OS_ANDROID) +void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup( + const gfx::Rect& target_rect, + const SkBitmap& zoomed_bitmap) { +} + +void RenderWidgetHostViewChildFrame::HasTouchEventHandlers( + bool need_touch_events) { +} +#endif // defined(OS_ANDROID) + +#if defined(TOOLKIT_GTK) +GdkEventButton* RenderWidgetHostViewChildFrame::GetLastMouseDown() { + return NULL; +} + +gfx::NativeView RenderWidgetHostViewChildFrame::BuildInputMethodsGtkMenu() { + return NULL; +} +#endif // defined(TOOLKIT_GTK) + +#if defined(OS_WIN) && !defined(USE_AURA) +void RenderWidgetHostViewChildFrame::WillWmDestroy() { +} +#endif // defined(OS_WIN) && !defined(USE_AURA) + +BackingStore* RenderWidgetHostViewChildFrame::AllocBackingStore( + const gfx::Size& size) { + NOTREACHED(); + return NULL; +} + +void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface( + const gfx::Rect& src_subrect, + const gfx::Size& /* dst_size */, + const base::Callback<void(bool, const SkBitmap&)>& callback) { + callback.Run(false, SkBitmap()); +} + +void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame( + const gfx::Rect& src_subrect, + const scoped_refptr<media::VideoFrame>& target, + const base::Callback<void(bool)>& callback) { + NOTIMPLEMENTED(); + callback.Run(false); +} + +bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const { + return false; +} + +void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() { + NOTREACHED(); +} + +void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() { +} + +bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface( + const gfx::Size& desired_size) { + return false; +} + +#if defined(OS_WIN) && !defined(USE_AURA) +void RenderWidgetHostViewChildFrame::SetClickthroughRegion(SkRegion* region) { +} +#endif // defined(OS_WIN) && !defined(USE_AURA) + +gfx::GLSurfaceHandle RenderWidgetHostViewChildFrame::GetCompositingSurface() { + return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); +} + +void RenderWidgetHostViewChildFrame::SetHasHorizontalScrollbar( + bool has_horizontal_scrollbar) { +} + +void RenderWidgetHostViewChildFrame::SetScrollOffsetPinning( + bool is_pinned_to_left, bool is_pinned_to_right) { +} + +#if defined(OS_WIN) && defined(USE_AURA) +void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) { +} + +gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin() + const { + return NULL; +} +#endif // defined(OS_WIN) && defined(USE_AURA) + +} // namespace content diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.h b/content/browser/frame_host/render_widget_host_view_child_frame.h new file mode 100644 index 0000000..5669c05 --- /dev/null +++ b/content/browser/frame_host/render_widget_host_view_child_frame.h @@ -0,0 +1,195 @@ +// Copyright 2014 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. + +#ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_ +#define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_ + +#include "base/memory/scoped_ptr.h" +#include "content/browser/renderer_host/render_widget_host_view_base.h" +#include "content/common/content_export.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/gfx/rect.h" + +namespace content { +class CrossProcessFrameConnector; +class RenderWidgetHost; +class RenderWidgetHostImpl; + +// RenderWidgetHostViewChildFrame implements the view for a RenderWidgetHost +// associated with content being rendered in a separate process from +// content that is embedding it. This is not a platform-specific class; rather, +// the embedding renderer process implements the platform containing the +// widget, and the top-level frame's RenderWidgetHostView will ultimately +// manage all native widget interaction. +// +// See comments in render_widget_host_view.h about this class and its members. +class CONTENT_EXPORT RenderWidgetHostViewChildFrame + : public RenderWidgetHostViewBase { + public: + explicit RenderWidgetHostViewChildFrame(RenderWidgetHost* widget); + virtual ~RenderWidgetHostViewChildFrame(); + + void set_cross_process_child_frame( + CrossProcessFrameConnector* frame_connector) { + frame_connector_ = frame_connector; + } + + // RenderWidgetHostView implementation. + virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; + virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; + virtual void SetSize(const gfx::Size& size) OVERRIDE; + virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual bool HasFocus() const OVERRIDE; + virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; + virtual void Show() OVERRIDE; + virtual void Hide() OVERRIDE; + virtual bool IsShowing() OVERRIDE; + virtual gfx::Rect GetViewBounds() const OVERRIDE; + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; + virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE; +#if defined(OS_WIN) && !defined(USE_AURA) + virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE; +#endif + + // RenderWidgetHostViewPort implementation. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE; + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE; + virtual void WasShown() OVERRIDE; + virtual void WasHidden() OVERRIDE; + virtual void MovePluginWindows( + const gfx::Vector2d& scroll_offset, + const std::vector<WebPluginGeometry>& moves) OVERRIDE; + virtual void Blur() OVERRIDE; + virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; + virtual void SetIsLoading(bool is_loading) OVERRIDE; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE; + virtual void ImeCancelComposition() OVERRIDE; +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) + virtual void ImeCompositionRangeChanged( + const gfx::Range& range, + const std::vector<gfx::Rect>& character_bounds) OVERRIDE; +#endif + virtual void DidUpdateBackingStore( + const gfx::Rect& scroll_rect, + const gfx::Vector2d& scroll_delta, + const std::vector<gfx::Rect>& copy_rects, + const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE; + virtual void RenderProcessGone(base::TerminationStatus status, + int error_code) OVERRIDE; + virtual void Destroy() OVERRIDE; + virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE; + virtual void SelectionChanged(const base::string16& text, + size_t offset, + const gfx::Range& range) OVERRIDE; + virtual void SelectionBoundsChanged( + const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; + virtual void ScrollOffsetChanged() OVERRIDE; + virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; + virtual void CopyFromCompositingSurface( + const gfx::Rect& src_subrect, + const gfx::Size& dst_size, + const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE; + virtual void CopyFromCompositingSurfaceToVideoFrame( + const gfx::Rect& src_subrect, + const scoped_refptr<media::VideoFrame>& target, + const base::Callback<void(bool)>& callback) OVERRIDE; + virtual bool CanCopyToVideoFrame() const OVERRIDE; + virtual void OnAcceleratedCompositingStateChange() OVERRIDE; + virtual void AcceleratedSurfaceInitialized(int host_id, + int route_id) OVERRIDE; + virtual void AcceleratedSurfaceBuffersSwapped( + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, + int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfaceSuspend() OVERRIDE; + virtual void AcceleratedSurfaceRelease() OVERRIDE; + virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; + virtual void OnSwapCompositorFrame( + uint32 output_surface_id, + scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; + virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE; + virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; + virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; + virtual void SetHasHorizontalScrollbar( + bool has_horizontal_scrollbar) OVERRIDE; + virtual void SetScrollOffsetPinning( + bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; +#if defined(OS_WIN) || defined(USE_AURA) + virtual void ProcessAckedTouchEvent( + const TouchEventWithLatencyInfo& touch, + InputEventAckState ack_result) OVERRIDE; +#endif // defined(OS_WIN) || defined(USE_AURA) + virtual bool LockMouse() OVERRIDE; + virtual void UnlockMouse() OVERRIDE; + +#if defined(OS_MACOSX) + // RenderWidgetHostView implementation. + virtual void SetActive(bool active) OVERRIDE; + virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; + virtual void SetWindowVisibility(bool visible) OVERRIDE; + virtual void WindowFrameChanged() OVERRIDE; + virtual void ShowDefinitionForSelection() OVERRIDE; + virtual bool SupportsSpeech() const OVERRIDE; + virtual void SpeakSelection() OVERRIDE; + virtual bool IsSpeaking() const OVERRIDE; + virtual void StopSpeaking() OVERRIDE; + + // RenderWidgetHostViewPort implementation. + virtual bool PostProcessEventForPluginIme( + const NativeWebKeyboardEvent& event) OVERRIDE; +#endif // defined(OS_MACOSX) + +#if defined(OS_ANDROID) + // RenderWidgetHostViewPort implementation. + virtual void ShowDisambiguationPopup( + const gfx::Rect& target_rect, + const SkBitmap& zoomed_bitmap) OVERRIDE; + virtual void HasTouchEventHandlers(bool need_touch_events) OVERRIDE; +#endif // defined(OS_ANDROID) + +#if defined(TOOLKIT_GTK) + virtual GdkEventButton* GetLastMouseDown() OVERRIDE; + virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; +#endif // defined(TOOLKIT_GTK) + +#if defined(OS_WIN) && !defined(USE_AURA) + virtual void WillWmDestroy() OVERRIDE; +#endif // defined(OS_WIN) && !defined(USE_AURA) + +#if defined(OS_WIN) && defined(USE_AURA) + virtual void SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) OVERRIDE; + virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE; +#endif + + protected: + friend class RenderWidgetHostView; + + // Members will become private when RenderWidgetHostViewGuest is removed. + // The model object. + RenderWidgetHostImpl* host_; + + // frame_connector_ provides a platform abstraction. Messages + // sent through it are routed to the embedding renderer process. + CrossProcessFrameConnector* frame_connector_; + + gfx::Size size_; + + private: + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrame); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_ diff --git a/content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc b/content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc new file mode 100644 index 0000000..25c19e1 --- /dev/null +++ b/content/browser/frame_host/render_widget_host_view_child_frame_unittest.cc @@ -0,0 +1,87 @@ +// Copyright 2014 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/browser/frame_host/render_widget_host_view_child_frame.h" + +#include "base/basictypes.h" +#include "base/message_loop/message_loop.h" +#include "content/browser/renderer_host/render_widget_host_delegate.h" +#include "content/browser/renderer_host/render_widget_host_impl.h" +#include "content/common/view_messages.h" +#include "content/public/browser/render_widget_host_view.h" +#include "content/public/test/mock_render_process_host.h" +#include "content/public/test/test_browser_context.h" +#include "content/test/test_render_view_host.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace content { +namespace { +class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { + public: + MockRenderWidgetHostDelegate() {} + virtual ~MockRenderWidgetHostDelegate() {} +}; + +class RenderWidgetHostViewChildFrameTest : public testing::Test { + public: + RenderWidgetHostViewChildFrameTest() {} + + virtual void SetUp() { + browser_context_.reset(new TestBrowserContext); + MockRenderProcessHost* process_host = + new MockRenderProcessHost(browser_context_.get()); + widget_host_ = new RenderWidgetHostImpl( + &delegate_, process_host, MSG_ROUTING_NONE, false); + view_ = new RenderWidgetHostViewChildFrame(widget_host_); + } + + virtual void TearDown() { + if (view_) + view_->Destroy(); + delete widget_host_; + + browser_context_.reset(); + + message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); + message_loop_.RunUntilIdle(); + } + + protected: + base::MessageLoopForUI message_loop_; + scoped_ptr<BrowserContext> browser_context_; + MockRenderWidgetHostDelegate delegate_; + + // Tests should set these to NULL if they've already triggered their + // destruction. + RenderWidgetHostImpl* widget_host_; + RenderWidgetHostViewChildFrame* view_; + + private: + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrameTest); +}; + +} // namespace + +TEST_F(RenderWidgetHostViewChildFrameTest, VisibilityTest) { + view_->Show(); + ASSERT_TRUE(view_->IsShowing()); + + view_->Hide(); + ASSERT_FALSE(view_->IsShowing()); + + view_->WasShown(); + ASSERT_TRUE(view_->IsShowing()); + + view_->WasHidden(); + ASSERT_FALSE(view_->IsShowing()); +} + +TEST_F(RenderWidgetHostViewChildFrameTest, SetSizeTest) { + gfx::Size size(100, 100); + + view_->SetSize(size); + ASSERT_TRUE(view_->GetViewBounds().size() == size); +} + +} // namespace content diff --git a/content/browser/renderer_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc index b0cd5e8..312f472 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.cc +++ b/content/browser/frame_host/render_widget_host_view_guest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 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. @@ -7,9 +7,10 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "content/browser/browser_plugin/browser_plugin_guest.h" +#include "content/browser/frame_host/render_widget_host_view_guest.h" #include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/browser/renderer_host/render_widget_host_view_guest.h" #include "content/common/browser_plugin/browser_plugin_messages.h" +#include "content/common/frame_messages.h" #include "content/common/gpu/gpu_messages.h" #include "content/common/view_messages.h" #include "content/common/webplugin_geometry.h" @@ -51,14 +52,13 @@ RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( RenderWidgetHost* widget_host, BrowserPluginGuest* guest, RenderWidgetHostView* platform_view) - : host_(RenderWidgetHostImpl::From(widget_host)), + : RenderWidgetHostViewChildFrame(widget_host), guest_(guest), platform_view_(static_cast<RenderWidgetHostViewPort*>(platform_view)) { #if defined(OS_WIN) || defined(USE_AURA) gesture_recognizer_.reset(ui::GestureRecognizer::Create()); gesture_recognizer_->AddGestureEventHelper(this); #endif // defined(OS_WIN) || defined(USE_AURA) - host_->SetView(this); } RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() { @@ -67,10 +67,6 @@ RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() { #endif // defined(OS_WIN) || defined(USE_AURA) } -RenderWidgetHost* RenderWidgetHostViewGuest::GetRenderWidgetHost() const { - return host_; -} - void RenderWidgetHostViewGuest::WasShown() { // If the WebContents associated with us showed an interstitial page in the // beginning, the teardown path might call WasShown() while |host_| is in @@ -96,13 +92,8 @@ void RenderWidgetHostViewGuest::SetSize(const gfx::Size& size) { host_->WasResized(); } -gfx::Rect RenderWidgetHostViewGuest::GetBoundsInRootWindow() { - // We do not have any root window specific parts in this view. - return GetViewBounds(); -} - -gfx::GLSurfaceHandle RenderWidgetHostViewGuest::GetCompositingSurface() { - return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); +void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) { + SetSize(rect.size()); } #if defined(OS_WIN) || defined(USE_AURA) @@ -129,18 +120,6 @@ void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( } #endif -void RenderWidgetHostViewGuest::Show() { - WasShown(); -} - -void RenderWidgetHostViewGuest::Hide() { - WasHidden(); -} - -bool RenderWidgetHostViewGuest::IsShowing() { - return !host_->is_hidden(); -} - gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { RenderWidgetHostViewPort* rwhv = static_cast<RenderWidgetHostViewPort*>( guest_->GetEmbedderRenderWidgetHostView()); @@ -169,28 +148,29 @@ void RenderWidgetHostViewGuest::Destroy() { platform_view_->Destroy(); } +gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { + return RenderWidgetHostViewBase::GetPhysicalBackingSize(); +} + void RenderWidgetHostViewGuest::SetTooltipText( const base::string16& tooltip_text) { platform_view_->SetTooltipText(tooltip_text); } -void RenderWidgetHostViewGuest::AcceleratedSurfaceInitialized(int host_id, - int route_id) { -} - void RenderWidgetHostViewGuest::AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) { // If accelerated surface buffers are getting swapped then we're not using // the software path. guest_->clear_damage_buffer(); - BrowserPluginMsg_BuffersSwapped_Params guest_params; + FrameMsg_BuffersSwapped_Params guest_params; guest_params.size = params.size; guest_params.mailbox_name = params.mailbox_name; - guest_params.route_id = params.route_id; - guest_params.host_id = gpu_host_id; + guest_params.gpu_route_id = params.route_id; + guest_params.gpu_host_id = gpu_host_id; guest_->SendMessageToEmbedder( - new BrowserPluginMsg_BuffersSwapped(guest_->instance_id(), guest_params)); + new BrowserPluginMsg_BuffersSwapped(guest_->instance_id(), + guest_params)); } void RenderWidgetHostViewGuest::AcceleratedSurfacePostSubBuffer( @@ -220,17 +200,16 @@ void RenderWidgetHostViewGuest::OnSwapCompositorFrame( } guest_->clear_damage_buffer(); - guest_->SendMessageToEmbedder( - new BrowserPluginMsg_CompositorFrameSwapped( - guest_->instance_id(), - *frame, - host_->GetRoutingID(), - output_surface_id, - host_->GetProcess()->GetID())); -} -void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) { - SetSize(rect.size()); + FrameMsg_CompositorFrameSwapped_Params guest_params; + frame->AssignTo(&guest_params.frame); + guest_params.output_surface_id = output_surface_id; + guest_params.producing_route_id = host_->GetRoutingID(); + guest_params.producing_host_id = host_->GetProcess()->GetID(); + + guest_->SendMessageToEmbedder( + new BrowserPluginMsg_CompositorFrameSwapped(guest_->instance_id(), + guest_params)); } bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { @@ -274,21 +253,6 @@ void RenderWidgetHostViewGuest::MovePluginWindows( platform_view_->MovePluginWindows(scroll_offset, moves); } -void RenderWidgetHostViewGuest::Focus() { -} - -void RenderWidgetHostViewGuest::Blur() { -} - -bool RenderWidgetHostViewGuest::HasFocus() const { - return false; -} - -bool RenderWidgetHostViewGuest::IsSurfaceAvailableForCopy() const { - NOTIMPLEMENTED(); - return false; -} - void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) { platform_view_->UpdateCursor(cursor); } @@ -367,15 +331,6 @@ void RenderWidgetHostViewGuest::SelectionBoundsChanged( rwhv->SelectionBoundsChanged(guest_params); } -void RenderWidgetHostViewGuest::ScrollOffsetChanged() { -} - -BackingStore* RenderWidgetHostViewGuest::AllocBackingStore( - const gfx::Size& size) { - NOTREACHED(); - return NULL; -} - void RenderWidgetHostViewGuest::CopyFromCompositingSurface( const gfx::Rect& src_subrect, const gfx::Size& dst_size, @@ -384,39 +339,10 @@ void RenderWidgetHostViewGuest::CopyFromCompositingSurface( guest_->CopyFromCompositingSurface(src_subrect, dst_size, callback); } -void RenderWidgetHostViewGuest::CopyFromCompositingSurfaceToVideoFrame( - const gfx::Rect& src_subrect, - const scoped_refptr<media::VideoFrame>& target, - const base::Callback<void(bool)>& callback) { - NOTIMPLEMENTED(); - callback.Run(false); -} - -bool RenderWidgetHostViewGuest::CanCopyToVideoFrame() const { - return false; -} - -void RenderWidgetHostViewGuest::AcceleratedSurfaceSuspend() { - NOTREACHED(); -} - -void RenderWidgetHostViewGuest::AcceleratedSurfaceRelease() { -} - -bool RenderWidgetHostViewGuest::HasAcceleratedSurface( - const gfx::Size& desired_size) { - return false; -} - void RenderWidgetHostViewGuest::SetBackground(const SkBitmap& background) { platform_view_->SetBackground(background); } -#if defined(OS_WIN) && !defined(USE_AURA) -void RenderWidgetHostViewGuest::SetClickthroughRegion(SkRegion* region) { -} -#endif - void RenderWidgetHostViewGuest::SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) { platform_view_->SetHasHorizontalScrollbar(has_horizontal_scrollbar); @@ -428,9 +354,6 @@ void RenderWidgetHostViewGuest::SetScrollOffsetPinning( is_pinned_to_left, is_pinned_to_right); } -void RenderWidgetHostViewGuest::OnAcceleratedCompositingStateChange() { -} - bool RenderWidgetHostViewGuest::LockMouse() { return platform_view_->LockMouse(); } diff --git a/content/browser/renderer_host/render_widget_host_view_guest.h b/content/browser/frame_host/render_widget_host_view_guest.h index 933c83b..151af55 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.h +++ b/content/browser/frame_host/render_widget_host_view_guest.h @@ -1,14 +1,14 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 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. -#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ -#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ +#ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ +#define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ #include <vector> #include "base/memory/scoped_ptr.h" -#include "content/browser/renderer_host/render_widget_host_view_base.h" +#include "content/browser/frame_host/render_widget_host_view_child_frame.h" #include "content/common/content_export.h" #include "ui/events/event.h" #include "ui/events/gestures/gesture_recognizer.h" @@ -28,16 +28,18 @@ class RenderWidgetHostImpl; class BrowserPluginGuest; struct NativeWebKeyboardEvent; -// ----------------------------------------------------------------------------- // See comments in render_widget_host_view.h about this class and its members. -// This version is for the webview plugin which handles a lot of the +// This version is for the BrowserPlugin which handles a lot of the // functionality in a diffent place and isn't platform specific. +// The BrowserPlugin is currently a special case for out-of-process rendered +// content and therefore inherits from RenderWidgetHostViewChildFrame. +// Eventually all RenderWidgetHostViewGuest code will be subsumed by +// RenderWidgetHostViewChildFrame and this class will be removed. // // Some elements that are platform specific will be deal with by delegating // the relevant calls to the platform view. -// ----------------------------------------------------------------------------- class CONTENT_EXPORT RenderWidgetHostViewGuest - : public RenderWidgetHostViewBase, + : public RenderWidgetHostViewChildFrame, public ui::GestureConsumer, public ui::GestureEventHelper { public: @@ -49,22 +51,14 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest // RenderWidgetHostView implementation. virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; - virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual bool HasFocus() const OVERRIDE; - virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; - virtual void Show() OVERRIDE; - virtual void Hide() OVERRIDE; - virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; virtual void SetBackground(const SkBitmap& background) OVERRIDE; -#if defined(OS_WIN) && !defined(USE_AURA) - virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE; -#endif + virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE; // RenderWidgetHostViewPort implementation. virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, @@ -76,8 +70,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest virtual void MovePluginWindows( const gfx::Vector2d& scroll_offset, const std::vector<WebPluginGeometry>& moves) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; virtual void TextInputTypeChanged(ui::TextInputType type, @@ -97,27 +89,16 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest virtual void RenderProcessGone(base::TerminationStatus status, int error_code) OVERRIDE; virtual void Destroy() OVERRIDE; - virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) {} virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE; virtual void SelectionChanged(const base::string16& text, size_t offset, const gfx::Range& range) OVERRIDE; virtual void SelectionBoundsChanged( const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; - virtual void ScrollOffsetChanged() OVERRIDE; - virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void CopyFromCompositingSurface( const gfx::Rect& src_subrect, const gfx::Size& dst_size, const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE; - virtual void CopyFromCompositingSurfaceToVideoFrame( - const gfx::Rect& src_subrect, - const scoped_refptr<media::VideoFrame>& target, - const base::Callback<void(bool)>& callback) OVERRIDE; - virtual bool CanCopyToVideoFrame() const OVERRIDE; - virtual void OnAcceleratedCompositingStateChange() OVERRIDE; - virtual void AcceleratedSurfaceInitialized(int host_id, - int route_id) OVERRIDE; virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) OVERRIDE; @@ -127,15 +108,10 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest virtual void OnSwapCompositorFrame( uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; - virtual void AcceleratedSurfaceSuspend() OVERRIDE; - virtual void AcceleratedSurfaceRelease() OVERRIDE; - virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; virtual void SetHasHorizontalScrollbar( bool has_horizontal_scrollbar) OVERRIDE; virtual void SetScrollOffsetPinning( bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; - virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; - virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; #if defined(OS_WIN) || defined(USE_AURA) virtual void ProcessAckedTouchEvent( const TouchEventWithLatencyInfo& touch, @@ -202,9 +178,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest // Process all of the given gestures (passes them on to renderer) void ProcessGestures(ui::GestureRecognizer::Gestures* gestures); - // The model object. - RenderWidgetHostImpl* host_; - BrowserPluginGuest *guest_; gfx::Size size_; // The platform view for this RenderWidgetHostView. @@ -219,4 +192,4 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest } // namespace content -#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ +#endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_GUEST_H_ diff --git a/content/browser/renderer_host/render_widget_host_view_guest_unittest.cc b/content/browser/frame_host/render_widget_host_view_guest_unittest.cc index b99743a..172be97 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest_unittest.cc +++ b/content/browser/frame_host/render_widget_host_view_guest_unittest.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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/browser/renderer_host/render_widget_host_view_guest.h" +#include "content/browser/frame_host/render_widget_host_view_guest.h" #include "base/basictypes.h" #include "base/message_loop/message_loop.h" diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc index cbfb790..475e864 100644 --- a/content/browser/web_contents/web_contents_view_guest.cc +++ b/content/browser/web_contents/web_contents_view_guest.cc @@ -8,9 +8,9 @@ #include "content/browser/browser_plugin/browser_plugin_embedder.h" #include "content/browser/browser_plugin/browser_plugin_guest.h" #include "content/browser/frame_host/interstitial_page_impl.h" +#include "content/browser/frame_host/render_widget_host_view_guest.h" #include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/browser/renderer_host/render_widget_host_view_guest.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/drag_messages.h" #include "content/public/browser/web_contents_delegate.h" diff --git a/content/common/browser_plugin/browser_plugin_messages.h b/content/common/browser_plugin/browser_plugin_messages.h index c85b229..be34c7b 100644 --- a/content/common/browser_plugin/browser_plugin_messages.h +++ b/content/common/browser_plugin/browser_plugin_messages.h @@ -15,6 +15,7 @@ #include "content/common/content_export.h" #include "content/common/content_param_traits.h" #include "content/common/edit_command.h" +#include "content/common/frame_param_macros.h" #include "content/public/common/browser_plugin_permission_type.h" #include "content/public/common/common_param_traits.h" #include "content/public/common/drop_data.h" @@ -85,14 +86,6 @@ IPC_STRUCT_BEGIN(BrowserPluginMsg_Attach_ACK_Params) IPC_STRUCT_MEMBER(std::string, name) IPC_STRUCT_END() -IPC_STRUCT_BEGIN(BrowserPluginMsg_BuffersSwapped_Params) - IPC_STRUCT_MEMBER(gfx::Size, size) - IPC_STRUCT_MEMBER(gfx::Rect, damage_rect) - IPC_STRUCT_MEMBER(std::string, mailbox_name) - IPC_STRUCT_MEMBER(int, route_id) - IPC_STRUCT_MEMBER(int, host_id) -IPC_STRUCT_END() - IPC_STRUCT_BEGIN(BrowserPluginMsg_UpdateRect_Params) // The sequence number of the damage buffer used by the browser process. IPC_STRUCT_MEMBER(uint32, damage_buffer_sequence_id) @@ -228,29 +221,11 @@ IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_NavigateGuest, int /* instance_id*/, std::string /* src */) -// Acknowledge that we presented a HW buffer and provide a sync point -// to specify the location in the command stream when the compositor -// is no longer using it. -IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_BuffersSwappedACK, - int /* instance_id */, - int /* route_id */, - int /* gpu_host_id */, - std::string /* mailbox_name */, - uint32 /* sync_point */) - IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, int /* instance_id */, int /* request_id */, SkBitmap); -// Acknowledge that we presented an ubercomp frame. -IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_CompositorFrameACK, - int /* instance_id */, - int /* route_id */, - uint32 /* output_surface_id */, - int /* renderer_host_id */, - cc::CompositorFrameAck /* ack */) - // Notify the guest renderer that some resources given to the embededer // are not used any more. IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_ReclaimCompositorResources, @@ -389,21 +364,31 @@ IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdatedName, std::string /* name */) // Guest renders into an FBO with textures provided by the embedder. -// When HW accelerated buffers are swapped in the guest, the message -// is forwarded to the embedder to notify it of a new texture -// available for compositing. +// BrowserPlugin shares mostly the same logic as out-of-process RenderFrames but +// because BrowserPlugins implement custom a second level of routing logic, +// the IPCs need to be annotated with an extra instance_id. These messages +// provide that extra id. IPC_MESSAGE_CONTROL2(BrowserPluginMsg_BuffersSwapped, int /* instance_id */, - BrowserPluginMsg_BuffersSwapped_Params) + FrameMsg_BuffersSwapped_Params /* params */) -IPC_MESSAGE_CONTROL5(BrowserPluginMsg_CompositorFrameSwapped, +IPC_MESSAGE_CONTROL2(BrowserPluginMsg_CompositorFrameSwapped, int /* instance_id */, - cc::CompositorFrame /* frame */, - int /* route_id */, - uint32 /* output_surface_id */, - int /* renderer_host_id */) + FrameMsg_CompositorFrameSwapped_Params /* params */) // Forwards a PointerLock Unlock request to the BrowserPlugin. IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock, int /* instance_id */, bool /* enable */) + +// See comment about BrowserPluginMsg_BuffersSwapped and +// BrowserPluginMsg_CompositorFrameSwapped for how these related +// to the FrameHostMsg variants. +IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_BuffersSwappedACK, + int /* instance_id */, + FrameHostMsg_BuffersSwappedACK_Params /* params */) + +// Acknowledge that we presented an ubercomp frame. +IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_CompositorFrameSwappedACK, + int /* instance_id */, + FrameHostMsg_CompositorFrameSwappedACK_Params /* params */) diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h index 87f769b5..7ea48ec 100644 --- a/content/common/frame_messages.h +++ b/content/common/frame_messages.h @@ -6,14 +6,41 @@ // Multiply-included message file, hence no include guard. #include "content/common/content_export.h" +#include "content/common/frame_param.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" +#include "url/gurl.h" #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START FrameMsgStart +// ----------------------------------------------------------------------------- +// Messages sent from the browser to the renderer. + +// When HW accelerated buffers are swapped in an out-of-process child frame +// renderer, the message is forwarded to the embedding frame to notify it of +// a new texture available for compositing. When the buffer has finished +// presenting, a FrameHostMsg_BuffersSwappedACK should be sent back to +// gpu host that produced this buffer. +// +// This is used in the non-ubercomp HW accelerated compositing path. +IPC_MESSAGE_ROUTED1(FrameMsg_BuffersSwapped, + FrameMsg_BuffersSwapped_Params /* params */) + +// Notifies the embedding frame that a new CompositorFrame is ready to be +// presented. When the frame finishes presenting, a matching +// FrameHostMsg_CompositorFrameSwappedACK should be sent back to the +// RenderViewHost that was produced the CompositorFrame. +// +// This is used in the ubercomp compositing path. +IPC_MESSAGE_ROUTED1(FrameMsg_CompositorFrameSwapped, + FrameMsg_CompositorFrameSwapped_Params /* params */) + +// ----------------------------------------------------------------------------- +// Messages sent from the renderer to the browser. + // Sent by the renderer when a child frame is created in the renderer. The // |parent_frame_id| and |frame_id| are NOT routing ids. They are // renderer-allocated identifiers used for tracking a frame's creation. @@ -85,3 +112,18 @@ IPC_SYNC_MESSAGE_CONTROL4_2(FrameHostMsg_OpenChannelToPlugin, std::string /* mime_type */, IPC::ChannelHandle /* channel_handle */, content::WebPluginInfo /* info */) + +// Acknowledge that we presented a HW buffer and provide a sync point +// to specify the location in the command stream when the compositor +// is no longer using it. +// +// See FrameMsg_BuffersSwapped. +IPC_MESSAGE_ROUTED1(FrameHostMsg_BuffersSwappedACK, + FrameHostMsg_BuffersSwappedACK_Params /* params */) + +// Acknowledge that we presented an ubercomp frame. +// +// See FrameMsg_CompositorFrameSwapped +IPC_MESSAGE_ROUTED1(FrameHostMsg_CompositorFrameSwappedACK, + FrameHostMsg_CompositorFrameSwappedACK_Params /* params */) + diff --git a/content/common/frame_param.cc b/content/common/frame_param.cc new file mode 100644 index 0000000..dbeaaa7 --- /dev/null +++ b/content/common/frame_param.cc @@ -0,0 +1,40 @@ +// Copyright 2014 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/common/frame_param.h" +#include "content/common/cc_messages.h" + +#define IPC_MESSAGE_IMPL +#include "content/common/frame_param_macros.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#undef CONTENT_COMMON_FRAME_PARAM_MACROS_H_ +#include "content/common/frame_param_macros.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.h" +#undef CONTENT_COMMON_FRAME_PARAM_MACROS_H_ +#include "content/common/frame_param_macros.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#undef CONTENT_COMMON_FRAME_PARAM_MACROS_H_ +#include "content/common/frame_param_macros.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#undef CONTENT_COMMON_FRAME_PARAM_MACROS_H_ +#include "content/common/frame_param_macros.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#undef CONTENT_COMMON_FRAME_PARAM_MACROS_H_ +#include "content/common/frame_param_macros.h" +} // namespace IPC diff --git a/content/common/frame_param.h b/content/common/frame_param.h new file mode 100644 index 0000000..29c4010 --- /dev/null +++ b/content/common/frame_param.h @@ -0,0 +1,10 @@ +// Copyright 2014 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. + +#ifndef CONTENT_COMMON_FRAME_PARAM_H_ +#define CONTENT_COMMON_FRAME_PARAM_H_ + +#include "content/common/frame_param_macros.h" + +#endif // CONTENT_COMMON_FRAME_PARAM_H_ diff --git a/content/common/frame_param_macros.h b/content/common/frame_param_macros.h new file mode 100644 index 0000000..ea1534d --- /dev/null +++ b/content/common/frame_param_macros.h @@ -0,0 +1,56 @@ +// Copyright 2014 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. + +// Allows for sharing of IPC param structures between BrowserPlugin code and +// RenderFrame code. All these should be folded directly back into the IPCs in +// frame_messages.h once BrowserPlugin has been fully converted over to use +// the RenderFrame infrastructure. +// +// TODO(ajwong): Remove once BrowserPlugin has been converted to use +// RenderFrames. http://crbug.com/330264 + +#ifndef CONTENT_COMMON_FRAME_PARAM_MACROS_H_ +#define CONTENT_COMMON_FRAME_PARAM_MACROS_H_ + +#include "cc/output/compositor_frame_ack.h" +#include "cc/output/compositor_frame.h" +#include "content/public/common/common_param_traits.h" +#include "ipc/ipc_message_macros.h" + +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT + +IPC_STRUCT_BEGIN(FrameMsg_BuffersSwapped_Params) + IPC_STRUCT_MEMBER(int, gpu_host_id) + IPC_STRUCT_MEMBER(int, gpu_route_id) + IPC_STRUCT_MEMBER(std::string, mailbox_name) + IPC_STRUCT_MEMBER(gfx::Size, size) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(FrameMsg_CompositorFrameSwapped_Params) + // Specifies which RenderWidget produced the CompositorFrame. + IPC_STRUCT_MEMBER(int, producing_host_id) + IPC_STRUCT_MEMBER(int, producing_route_id) + + IPC_STRUCT_MEMBER(cc::CompositorFrame, frame) + IPC_STRUCT_MEMBER(uint32, output_surface_id) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(FrameHostMsg_BuffersSwappedACK_Params) + IPC_STRUCT_MEMBER(int, gpu_host_id) + IPC_STRUCT_MEMBER(int, gpu_route_id) + IPC_STRUCT_MEMBER(std::string, mailbox_name) + IPC_STRUCT_MEMBER(uint32, sync_point) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(FrameHostMsg_CompositorFrameSwappedACK_Params) + // Specifies which RenderWidget produced the CompositorFrame. + IPC_STRUCT_MEMBER(int, producing_host_id) + IPC_STRUCT_MEMBER(int, producing_route_id) + + IPC_STRUCT_MEMBER(uint32, output_surface_id) + IPC_STRUCT_MEMBER(cc::CompositorFrameAck, ack) +IPC_STRUCT_END() + +#endif // CONTENT_COMMON_FRAME_PARAM_MACROS_H_ diff --git a/content/content_browser.gypi b/content/content_browser.gypi index c8818ab..ddf7094 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -526,6 +526,8 @@ 'browser/frame_host/navigator_impl.cc', 'browser/frame_host/navigator_impl.h', 'browser/frame_host/navigator_delegate.h', + 'browser/frame_host/cross_process_frame_connector.cc', + 'browser/frame_host/cross_process_frame_connector.h', 'browser/frame_host/render_frame_host_delegate.cc', 'browser/frame_host/render_frame_host_delegate.h', 'browser/frame_host/render_frame_host_factory.cc', @@ -536,6 +538,10 @@ 'browser/frame_host/render_frame_host_manager.h', 'browser/frame_host/render_frame_message_filter.cc', 'browser/frame_host/render_frame_message_filter.h', + 'browser/frame_host/render_widget_host_view_child_frame.cc', + 'browser/frame_host/render_widget_host_view_child_frame.h', + 'browser/frame_host/render_widget_host_view_guest.cc', + 'browser/frame_host/render_widget_host_view_guest.h', 'browser/gamepad/gamepad_data_fetcher.h', 'browser/gamepad/gamepad_platform_data_fetcher.h', 'browser/gamepad/gamepad_platform_data_fetcher_linux.cc', @@ -1047,8 +1053,6 @@ 'browser/renderer_host/render_widget_host_view_base.h', 'browser/renderer_host/render_widget_host_view_gtk.cc', 'browser/renderer_host/render_widget_host_view_gtk.h', - 'browser/renderer_host/render_widget_host_view_guest.cc', - 'browser/renderer_host/render_widget_host_view_guest.h', 'browser/renderer_host/render_widget_host_view_mac_dictionary_helper.h', 'browser/renderer_host/render_widget_host_view_mac_dictionary_helper.mm', 'browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h', diff --git a/content/content_common.gypi b/content/content_common.gypi index 2a89197..17c52ca 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -179,6 +179,9 @@ 'common/font_list_ozone.cc', 'common/font_list_pango.cc', 'common/font_list_win.cc', + 'common/frame_param.cc', + 'common/frame_param.h', + 'common/frame_param_macros.h', 'common/gamepad_hardware_buffer.h', 'common/gamepad_messages.h', 'common/gamepad_user_gesture.cc', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 9ea60f9..16b01d4 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -374,6 +374,8 @@ 'browser/frame_host/navigation_controller_impl_unittest.cc', 'browser/frame_host/navigation_entry_impl_unittest.cc', 'browser/frame_host/render_frame_host_manager_unittest.cc', + 'browser/frame_host/render_widget_host_view_child_frame_unittest.cc', + 'browser/frame_host/render_widget_host_view_guest_unittest.cc', 'browser/gamepad/gamepad_provider_unittest.cc', 'browser/gamepad/gamepad_test_helpers.cc', 'browser/gamepad/gamepad_test_helpers.h', @@ -452,7 +454,6 @@ 'browser/renderer_host/render_view_host_unittest.cc', 'browser/renderer_host/render_widget_host_unittest.cc', 'browser/renderer_host/render_widget_host_view_aura_unittest.cc', - 'browser/renderer_host/render_widget_host_view_guest_unittest.cc', 'browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm', 'browser/renderer_host/render_widget_host_view_mac_unittest.mm', 'browser/renderer_host/software_frame_manager_unittest.cc', diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index 5f88fe1..eb67048 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -432,15 +432,14 @@ void BrowserPlugin::OnAttachACK( } void BrowserPlugin::OnBuffersSwapped( - int guest_instance_id, - const BrowserPluginMsg_BuffersSwapped_Params& params) { - DCHECK(guest_instance_id == guest_instance_id_); + int instance_id, + const FrameMsg_BuffersSwapped_Params& params) { EnableCompositing(true); compositing_helper_->OnBuffersSwapped(params.size, params.mailbox_name, - params.route_id, - params.host_id, + params.gpu_route_id, + params.gpu_host_id, GetDeviceScaleFactor()); } @@ -449,13 +448,13 @@ void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, ¶m)) return; scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); - param.b.AssignTo(frame.get()); + param.b.frame.AssignTo(frame.get()); EnableCompositing(true); compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), - param.c /* route_id */, - param.d /* output_surface_id */, - param.e /* host_id */); + param.b.producing_route_id, + param.b.output_surface_id, + param.b.producing_host_id); } void BrowserPlugin::OnCopyFromCompositingSurface(int guest_instance_id, diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h index d2b21aa..162c8de 100644 --- a/content/renderer/browser_plugin/browser_plugin.h +++ b/content/renderer/browser_plugin/browser_plugin.h @@ -25,8 +25,8 @@ struct BrowserPluginHostMsg_AutoSize_Params; struct BrowserPluginHostMsg_ResizeGuest_Params; struct BrowserPluginMsg_Attach_ACK_Params; -struct BrowserPluginMsg_BuffersSwapped_Params; struct BrowserPluginMsg_UpdateRect_Params; +struct FrameMsg_BuffersSwapped_Params; namespace content { @@ -296,7 +296,7 @@ class CONTENT_EXPORT BrowserPlugin : void OnAttachACK(int instance_id, const BrowserPluginMsg_Attach_ACK_Params& ack_params); void OnBuffersSwapped(int instance_id, - const BrowserPluginMsg_BuffersSwapped_Params& params); + const FrameMsg_BuffersSwapped_Params& params); void OnCompositorFrameSwapped(const IPC::Message& message); void OnCopyFromCompositingSurface(int instance_id, int request_id, diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc index a3ce844..89916e2 100644 --- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc +++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc @@ -14,6 +14,7 @@ #include "cc/output/copy_output_result.h" #include "cc/resources/single_release_callback.h" #include "content/common/browser_plugin/browser_plugin_messages.h" +#include "content/common/frame_messages.h" #include "content/common/gpu/client/context_provider_command_buffer.h" #include "content/renderer/browser_plugin/browser_plugin_manager.h" #include "content/renderer/render_thread_impl.h" @@ -73,37 +74,38 @@ void BrowserPluginCompositingHelper::CopyFromCompositingSurface( void BrowserPluginCompositingHelper::DidCommitCompositorFrame() { if (software_ack_pending_) { - cc::CompositorFrameAck ack; + FrameHostMsg_CompositorFrameSwappedACK_Params params; + params.producing_host_id = last_host_id_; + params.producing_route_id = last_route_id_; + params.output_surface_id = last_output_surface_id_; if (!unacked_software_frames_.empty()) { - ack.last_software_frame_id = unacked_software_frames_.back(); + params.ack.last_software_frame_id = unacked_software_frames_.back(); unacked_software_frames_.pop_back(); } browser_plugin_manager_->Send( - new BrowserPluginHostMsg_CompositorFrameACK( + new BrowserPluginHostMsg_CompositorFrameSwappedACK( host_routing_id_, instance_id_, - last_route_id_, - last_output_surface_id_, - last_host_id_, - ack)); + params)); software_ack_pending_ = false; } if (!resource_collection_.get() || !ack_pending_) return; - cc::CompositorFrameAck ack; - resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); + FrameHostMsg_CompositorFrameSwappedACK_Params params; + params.producing_host_id = last_host_id_; + params.producing_route_id = last_route_id_; + params.output_surface_id = last_output_surface_id_; + resource_collection_->TakeUnusedResourcesForChildCompositor( + ¶ms.ack.resources); browser_plugin_manager_->Send( - new BrowserPluginHostMsg_CompositorFrameACK( + new BrowserPluginHostMsg_CompositorFrameSwappedACK( host_routing_id_, instance_id_, - last_route_id_, - last_output_surface_id_, - last_host_id_, - ack)); + params)); ack_pending_ = false; } @@ -173,31 +175,33 @@ void BrowserPluginCompositingHelper::MailboxReleased( case TEXTURE_IMAGE_TRANSPORT: { std::string mailbox_name(reinterpret_cast<const char*>(mailbox.name.name), sizeof(mailbox.name.name)); + FrameHostMsg_BuffersSwappedACK_Params params; + params.gpu_host_id = mailbox.host_id; + params.gpu_route_id = mailbox.route_id; + params.mailbox_name = mailbox_name; + params.sync_point = sync_point; browser_plugin_manager_->Send( new BrowserPluginHostMsg_BuffersSwappedACK( host_routing_id_, instance_id_, - mailbox.route_id, - mailbox.host_id, - mailbox_name, - sync_point)); + params)); break; } case GL_COMPOSITOR_FRAME: { - cc::CompositorFrameAck ack; - ack.gl_frame_data.reset(new cc::GLFrameData()); - ack.gl_frame_data->mailbox = mailbox.name; - ack.gl_frame_data->size = mailbox.size; - ack.gl_frame_data->sync_point = sync_point; + FrameHostMsg_CompositorFrameSwappedACK_Params params; + params.producing_host_id = mailbox.host_id; + params.producing_route_id = mailbox.route_id; + params.output_surface_id = mailbox.output_surface_id; + params.ack.gl_frame_data.reset(new cc::GLFrameData()); + params.ack.gl_frame_data->mailbox = mailbox.name; + params.ack.gl_frame_data->size = mailbox.size; + params.ack.gl_frame_data->sync_point = sync_point; browser_plugin_manager_->Send( - new BrowserPluginHostMsg_CompositorFrameACK( + new BrowserPluginHostMsg_CompositorFrameSwappedACK( host_routing_id_, instance_id_, - mailbox.route_id, - mailbox.output_surface_id, - mailbox.host_id, - ack)); + params)); break; } case SOFTWARE_COMPOSITOR_FRAME: |