diff options
author | nasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 20:04:27 +0000 |
---|---|---|
committer | nasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 20:04:27 +0000 |
commit | e3244ed5c3e962e70a4d5fd7326356b0ffd3ffe6 (patch) | |
tree | 13ca5648f6ece3879581fbfbbe358ba50dbc8b9f | |
parent | 30e5fe97e3b64a7361792c26259faf24414e7a3d (diff) | |
download | chromium_src-e3244ed5c3e962e70a4d5fd7326356b0ffd3ffe6.zip chromium_src-e3244ed5c3e962e70a4d5fd7326356b0ffd3ffe6.tar.gz chromium_src-e3244ed5c3e962e70a4d5fd7326356b0ffd3ffe6.tar.bz2 |
Move ownership of ChildFrameCompositingHelper from frame to proxy.
The ChildFrameCompositingHelper is used for swapped out RenderFrames only, which I want to eliminate and replace with RenderFrameProxy. As such, it is the RFP object that should own the helper.
BUG=357747
Review URL: https://codereview.chromium.org/345823002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278808 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/child_frame_compositing_helper.cc | 22 | ||||
-rw-r--r-- | content/renderer/child_frame_compositing_helper.h | 8 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.cc | 52 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.h | 5 | ||||
-rw-r--r-- | content/renderer/render_frame_proxy.cc | 59 | ||||
-rw-r--r-- | content/renderer/render_frame_proxy.h | 16 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 24 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 11 |
8 files changed, 105 insertions, 92 deletions
diff --git a/content/renderer/child_frame_compositing_helper.cc b/content/renderer/child_frame_compositing_helper.cc index fee5ab7..8790ae2 100644 --- a/content/renderer/child_frame_compositing_helper.cc +++ b/content/renderer/child_frame_compositing_helper.cc @@ -20,6 +20,7 @@ #include "content/renderer/browser_plugin/browser_plugin_manager.h" #include "content/renderer/compositor_bindings/web_layer_impl.h" #include "content/renderer/render_frame_impl.h" +#include "content/renderer/render_frame_proxy.h" #include "content/renderer/render_thread_impl.h" #include "skia/ext/image_operations.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" @@ -48,16 +49,17 @@ ChildFrameCompositingHelper::CreateCompositingHelperForBrowserPlugin( ChildFrameCompositingHelper* ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( blink::WebFrame* frame, - RenderFrameImpl* render_frame, + RenderFrameProxy* render_frame_proxy, int host_routing_id) { return new ChildFrameCompositingHelper( - base::WeakPtr<BrowserPlugin>(), frame, render_frame, host_routing_id); + base::WeakPtr<BrowserPlugin>(), frame, render_frame_proxy, + host_routing_id); } ChildFrameCompositingHelper::ChildFrameCompositingHelper( const base::WeakPtr<BrowserPlugin>& browser_plugin, blink::WebFrame* frame, - RenderFrameImpl* render_frame, + RenderFrameProxy* render_frame_proxy, int host_routing_id) : host_routing_id_(host_routing_id), last_route_id_(0), @@ -68,7 +70,7 @@ ChildFrameCompositingHelper::ChildFrameCompositingHelper( software_ack_pending_(false), opaque_(true), browser_plugin_(browser_plugin), - render_frame_(render_frame), + render_frame_proxy_(render_frame_proxy), frame_(frame) {} ChildFrameCompositingHelper::~ChildFrameCompositingHelper() {} @@ -102,8 +104,8 @@ void ChildFrameCompositingHelper::SendCompositorFrameSwappedACKToBrowser( GetBrowserPluginManager()->Send( new BrowserPluginHostMsg_CompositorFrameSwappedACK( host_routing_id_, GetInstanceID(), params)); - } else if (render_frame_) { - render_frame_->Send( + } else if (render_frame_proxy_) { + render_frame_proxy_->Send( new FrameHostMsg_CompositorFrameSwappedACK(host_routing_id_, params)); } } @@ -115,8 +117,8 @@ void ChildFrameCompositingHelper::SendBuffersSwappedACKToBrowser( if (GetBrowserPluginManager()) { GetBrowserPluginManager()->Send(new BrowserPluginHostMsg_BuffersSwappedACK( host_routing_id_, params)); - } else if (render_frame_) { - render_frame_->Send( + } else if (render_frame_proxy_) { + render_frame_proxy_->Send( new FrameHostMsg_BuffersSwappedACK(host_routing_id_, params)); } } @@ -129,8 +131,8 @@ void ChildFrameCompositingHelper::SendReclaimCompositorResourcesToBrowser( GetBrowserPluginManager()->Send( new BrowserPluginHostMsg_ReclaimCompositorResources( host_routing_id_, GetInstanceID(), params)); - } else if (render_frame_) { - render_frame_->Send( + } else if (render_frame_proxy_) { + render_frame_proxy_->Send( new FrameHostMsg_ReclaimCompositorResources(host_routing_id_, params)); } } diff --git a/content/renderer/child_frame_compositing_helper.h b/content/renderer/child_frame_compositing_helper.h index c33083e..d66ae3f 100644 --- a/content/renderer/child_frame_compositing_helper.h +++ b/content/renderer/child_frame_compositing_helper.h @@ -50,7 +50,7 @@ namespace content { class BrowserPlugin; class BrowserPluginManager; -class RenderFrameImpl; +class RenderFrameProxy; class CONTENT_EXPORT ChildFrameCompositingHelper : public base::RefCounted<ChildFrameCompositingHelper>, @@ -60,7 +60,7 @@ class CONTENT_EXPORT ChildFrameCompositingHelper const base::WeakPtr<BrowserPlugin>& browser_plugin); static ChildFrameCompositingHelper* CreateCompositingHelperForRenderFrame( blink::WebFrame* frame, - RenderFrameImpl* render_frame, + RenderFrameProxy* render_frame_proxy, int host_routing_id); void CopyFromCompositingSurface(int request_id, @@ -94,7 +94,7 @@ class CONTENT_EXPORT ChildFrameCompositingHelper ChildFrameCompositingHelper( const base::WeakPtr<BrowserPlugin>& browser_plugin, blink::WebFrame* frame, - RenderFrameImpl* render_frame, + RenderFrameProxy* render_frame_proxy, int host_routing_id); enum SwapBuffersType { @@ -157,7 +157,7 @@ class CONTENT_EXPORT ChildFrameCompositingHelper // other member objects, as they may access this pointer during their // destruction. base::WeakPtr<BrowserPlugin> browser_plugin_; - RenderFrameImpl* render_frame_; + RenderFrameProxy* render_frame_proxy_; scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index c806ac3..8636b6e 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -683,10 +683,6 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload) IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) - IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped) - IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped, - OnCompositorFrameSwapped(msg)) - IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, OnCustomContextMenuAction) @@ -969,9 +965,6 @@ void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { // beforeunload handler. For now, we just run it a second time silently. render_view_->NavigateToSwappedOutURL(frame_); - if (frame_->parent()) - render_view_->RegisterSwappedOutChildFrame(this); - // Let WebKit know that this view is hidden so it can drop resources and // stop compositing. // TODO(creis): Support this for subframes as well. @@ -994,42 +987,6 @@ void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { set_render_frame_proxy(proxy); } -void RenderFrameImpl::OnBuffersSwapped( - const FrameMsg_BuffersSwapped_Params& params) { - if (!compositing_helper_.get()) { - compositing_helper_ = - ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( - frame_, this, routing_id_); - compositing_helper_->EnableCompositing(true); - } - compositing_helper_->OnBuffersSwapped( - params.size, - params.mailbox, - params.gpu_route_id, - params.gpu_host_id, - render_view_->GetWebView()->deviceScaleFactor()); -} - -void RenderFrameImpl::OnCompositorFrameSwapped(const IPC::Message& message) { - FrameMsg_CompositorFrameSwapped::Param param; - if (!FrameMsg_CompositorFrameSwapped::Read(&message, ¶m)) - return; - scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); - param.a.frame.AssignTo(frame.get()); - - if (!compositing_helper_.get()) { - compositing_helper_ = - ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( - frame_, this, routing_id_); - compositing_helper_->EnableCompositing(true); - } - compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), - param.a.producing_route_id, - param.a.output_surface_id, - param.a.producing_host_id, - param.a.shared_memory_handle); -} - void RenderFrameImpl::OnContextMenuClosed( const CustomContextMenuContext& custom_context) { if (custom_context.request_id) { @@ -1277,8 +1234,6 @@ void RenderFrameImpl::LoadNavigationErrorPage( } void RenderFrameImpl::DidCommitCompositorFrame() { - if (compositing_helper_) - compositing_helper_->DidCommitCompositorFrame(); FOR_EACH_OBSERVER( RenderFrameObserver, observers_, DidCommitCompositorFrame()); } @@ -1355,11 +1310,6 @@ void RenderFrameImpl::ExecuteJavaScript(const base::string16& javascript) { OnJavaScriptExecuteRequest(javascript, 0, false); } -void RenderFrameImpl::OnChildFrameProcessGone() { - if (compositing_helper_) - compositing_helper_->ChildFrameGone(); -} - // blink::WebFrameClient implementation ---------------------------------------- blink::WebPlugin* RenderFrameImpl::createPlugin( @@ -1554,8 +1504,6 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { Send(new FrameHostMsg_Detach(routing_id_)); - render_view_->UnregisterSwappedOutChildFrame(this); - // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be // sent before setting |is_detaching_| to true. In contrast, Observers // should only be notified afterwards so they cannot call back into here and diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index b14b2a0..97cd4eb 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -31,8 +31,6 @@ #endif class TransportDIB; -struct FrameMsg_BuffersSwapped_Params; -struct FrameMsg_CompositorFrameSwapped_Params; struct FrameMsg_Navigate_Params; namespace blink { @@ -433,9 +431,6 @@ class CONTENT_EXPORT RenderFrameImpl // content/common/*_messages.h for the message that the function is handling. void OnBeforeUnload(); void OnSwapOut(int proxy_routing_id); - void OnChildFrameProcessGone(); - void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); - void OnCompositorFrameSwapped(const IPC::Message& message); void OnShowContextMenu(const gfx::Point& location); void OnContextMenuClosed(const CustomContextMenuContext& custom_context); void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context, diff --git a/content/renderer/render_frame_proxy.cc b/content/renderer/render_frame_proxy.cc index f964324..2e85a52 100644 --- a/content/renderer/render_frame_proxy.cc +++ b/content/renderer/render_frame_proxy.cc @@ -9,9 +9,11 @@ #include "base/lazy_instance.h" #include "content/common/frame_messages.h" #include "content/common/swapped_out_messages.h" +#include "content/renderer/child_frame_compositing_helper.h" #include "content/renderer/render_frame_impl.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/render_view_impl.h" +#include "third_party/WebKit/public/web/WebView.h" namespace content { @@ -48,17 +50,32 @@ RenderFrameProxy::RenderFrameProxy(int routing_id, int frame_routing_id) render_frame_ = RenderFrameImpl::FromRoutingID(frame_routing_id); CHECK(render_frame_); + render_frame_->render_view()->RegisterRenderFrameProxy(this); } RenderFrameProxy::~RenderFrameProxy() { + render_frame_->render_view()->UnregisterRenderFrameProxy(this); RenderThread::Get()->RemoveRoute(routing_id_); g_routing_id_proxy_map.Get().erase(routing_id_); } +blink::WebFrame* RenderFrameProxy::GetWebFrame() { + return render_frame_->GetWebFrame(); +} + +void RenderFrameProxy::DidCommitCompositorFrame() { + if (compositing_helper_) + compositing_helper_->DidCommitCompositorFrame(); +} + bool RenderFrameProxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(RenderFrameProxy, msg) IPC_MESSAGE_HANDLER(FrameMsg_DeleteProxy, OnDeleteProxy) + IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) + IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped) + IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped, + OnCompositorFrameSwapped(msg)) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -86,4 +103,46 @@ void RenderFrameProxy::OnDeleteProxy() { delete this; } +void RenderFrameProxy::OnChildFrameProcessGone() { + if (compositing_helper_) + compositing_helper_->ChildFrameGone(); +} + +void RenderFrameProxy::OnBuffersSwapped( + const FrameMsg_BuffersSwapped_Params& params) { + if (!compositing_helper_.get()) { + compositing_helper_ = + ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( + GetWebFrame(), this, routing_id_); + compositing_helper_->EnableCompositing(true); + } + compositing_helper_->OnBuffersSwapped( + params.size, + params.mailbox, + params.gpu_route_id, + params.gpu_host_id, + render_frame_->render_view()->GetWebView()->deviceScaleFactor()); +} + +void RenderFrameProxy::OnCompositorFrameSwapped(const IPC::Message& message) { + FrameMsg_CompositorFrameSwapped::Param param; + if (!FrameMsg_CompositorFrameSwapped::Read(&message, ¶m)) + return; + + scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); + param.a.frame.AssignTo(frame.get()); + + if (!compositing_helper_.get()) { + compositing_helper_ = + ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( + GetWebFrame(), this, routing_id_); + compositing_helper_->EnableCompositing(true); + } + compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), + param.a.producing_route_id, + param.a.output_surface_id, + param.a.producing_host_id, + param.a.shared_memory_handle); +} + } // namespace diff --git a/content/renderer/render_frame_proxy.h b/content/renderer/render_frame_proxy.h index f05371d..54c6361 100644 --- a/content/renderer/render_frame_proxy.h +++ b/content/renderer/render_frame_proxy.h @@ -6,6 +6,7 @@ #define CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ #include "base/basictypes.h" +#include "base/memory/ref_counted.h" #include "content/common/content_export.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_sender.h" @@ -13,8 +14,12 @@ #include "third_party/WebKit/public/web/WebFrameClient.h" #include "third_party/WebKit/public/web/WebRemoteFrame.h" +struct FrameMsg_BuffersSwapped_Params; +struct FrameMsg_CompositorFrameSwapped_Params; + namespace content { +class ChildFrameCompositingHelper; class RenderFrameImpl; class RenderViewImpl; @@ -58,6 +63,10 @@ class CONTENT_EXPORT RenderFrameProxy return render_frame_; } + // Out-of-process child frames receive a signal from RenderWidgetCompositor + // when a compositor frame has committed. + void DidCommitCompositorFrame(); + private: RenderFrameProxy(int routing_id, int frame_routing_id); @@ -66,11 +75,18 @@ class CONTENT_EXPORT RenderFrameProxy // IPC handlers void OnDeleteProxy(); + void OnChildFrameProcessGone(); + void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); + void OnCompositorFrameSwapped(const IPC::Message& message); + + blink::WebFrame* GetWebFrame(); int routing_id_; int frame_routing_id_; RenderFrameImpl* render_frame_; + scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; + DISALLOW_COPY_AND_ASSIGN(RenderFrameProxy); }; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index a3f1e59..38af273 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -43,6 +43,7 @@ #include "content/renderer/input/input_handler_manager.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" #include "content/renderer/render_frame_impl.h" +#include "content/renderer/render_frame_proxy.h" #include "content/renderer/render_process.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/renderer_webkitplatformsupport_impl.h" @@ -1199,20 +1200,11 @@ void RenderWidget::didBecomeReadyForAdditionalInput() { } void RenderWidget::DidCommitCompositorFrame() { - FOR_EACH_OBSERVER(RenderFrameImpl, swapped_out_frames_, + FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, DidCommitCompositorFrame()); #if defined(VIDEO_HOLE) - // Not using FOR_EACH_OBSERVER because |swapped_out_frames_| and - // |video_hole_frames_| may have common frames. - if (!video_hole_frames_.might_have_observers()) - return; - ObserverListBase<RenderFrameImpl>::Iterator iter(video_hole_frames_); - RenderFrameImpl* frame; - while ((frame = iter.GetNext()) != NULL) { - // Prevent duplicate notification of DidCommitCompositorFrame(). - if (!swapped_out_frames_.HasObserver(frame)) - frame->DidCommitCompositorFrame(); - } + FOR_EACH_OBSERVER(RenderFrameImpl, video_hole_frames_, + DidCommitCompositorFrame()); #endif // defined(VIDEO_HOLE) } @@ -2048,12 +2040,12 @@ RenderWidget::CreateGraphicsContext3D() { return context.Pass(); } -void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { - swapped_out_frames_.AddObserver(frame); +void RenderWidget::RegisterRenderFrameProxy(RenderFrameProxy* proxy) { + render_frame_proxies_.AddObserver(proxy); } -void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { - swapped_out_frames_.RemoveObserver(frame); +void RenderWidget::UnregisterRenderFrameProxy(RenderFrameProxy* proxy) { + render_frame_proxies_.RemoveObserver(proxy); } void RenderWidget::RegisterRenderFrame(RenderFrameImpl* frame) { diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index fb6c362..7c8e948 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -69,6 +69,7 @@ namespace content { class ExternalPopupMenu; class PepperPluginInstanceImpl; class RenderFrameImpl; +class RenderFrameProxy; class RenderWidgetCompositor; class RenderWidgetTest; class ResizingModeSelector; @@ -110,8 +111,8 @@ class CONTENT_EXPORT RenderWidget } // Functions to track out-of-process frames for special notifications. - void RegisterSwappedOutChildFrame(RenderFrameImpl* frame); - void UnregisterSwappedOutChildFrame(RenderFrameImpl* frame); + void RegisterRenderFrameProxy(RenderFrameProxy* proxy); + void UnregisterRenderFrameProxy(RenderFrameProxy* proxy); // Functions to track all RenderFrame objects associated with this // RenderWidget. @@ -692,9 +693,9 @@ class CONTENT_EXPORT RenderWidget scoped_ptr<ResizingModeSelector> resizing_mode_selector_; - // Lists of swapped out RenderFrames that need to be notified - // of compositing-related events (e.g. DidCommitCompositorFrame). - ObserverList<RenderFrameImpl> swapped_out_frames_; + // Lists of RenderFrameProxy objects that need to be notified of + // compositing-related events (e.g. DidCommitCompositorFrame). + ObserverList<RenderFrameProxy> render_frame_proxies_; #if defined(VIDEO_HOLE) ObserverList<RenderFrameImpl> video_hole_frames_; #endif // defined(VIDEO_HOLE) |