Commit f4675d46 authored by ccameron@chromium.org's avatar ccameron@chromium.org

Separate ResizeHelper from RenderWidgetHelper

Create a separate RenderWidgetResizeHelper to handle intercepting 
and early-processing of IPCs that need to be run during an active 
resize. This functionality was previously handled in 
RenderWidgetHelper. 

The only functional changes made to RenderWidgetResizeHelper during 
its excision is that it is a single global structure, as compared with
the per-RenderProcessImpl RenderWidgetHelper. It will execute any IPCs
from any renderer or the GPU processes that are forwarded to it. This is
preferable, as that makes it so that live resize in one window does 
not destroy performance in other windows. 

Because RenderWidgetResizeHelper can handle GPU process IPCs, we can 
tear out the bizarre behavior where we'd translate GPU IPCs to synthetic 
renderer IPCs get them to channel through RenderWidgetHelper (this is 
all of the deleted ViewHostMsg_CompositorSurfaceBuffersSwapped code). 

Mark this entire structure as Mac-only, and put it in Mac-only files,
since it doesn't get used on other platforms.

Future changes will make RenderWidgetResizeHelper have a TaskRunner, 
which we will pass to the compositor, so that we can pump new frames 
while inside -[RenderWidgetHostViewMac setFrameSize:].

BUG=392031

Review URL: https://codereview.chromium.org/396483003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283726 0039d316-1c4b-4281-b951-d872f2087c98
parent 740af6b7
......@@ -47,7 +47,7 @@ class BrowserTestBase;
class GLHelper;
class GpuChannelHost;
class NestedMessagePumpAndroid;
class RenderWidgetHelper;
class RenderWidgetResizeHelper;
class ScopedAllowWaitForAndroidLayoutTests;
class TextInputClientMac;
}
......@@ -180,7 +180,7 @@ class BASE_EXPORT ThreadRestrictions {
friend class content::BrowserShutdownProfileDumper;
friend class content::BrowserTestBase;
friend class content::NestedMessagePumpAndroid;
friend class content::RenderWidgetHelper;
friend class content::RenderWidgetResizeHelper;
friend class content::ScopedAllowWaitForAndroidLayoutTests;
friend class ::HistogramSynchronizer;
friend class ::ScopedAllowWaitForLegacyWebViewApi;
......
......@@ -17,11 +17,12 @@
#include "base/sha1.h"
#include "base/threading/thread.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_resize_helper.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/view_messages.h"
......@@ -42,6 +43,11 @@
#include "ui/events/latency_info.h"
#include "ui/gl/gl_switches.h"
#if defined(OS_MACOSX)
#include <IOSurface/IOSurfaceAPI.h>
#include "base/mac/scoped_cftyperef.h"
#include "content/common/gpu/surface_handle_types_mac.h"
#endif
#if defined(OS_WIN)
#include "base/win/windows_version.h"
......@@ -576,8 +582,8 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats,
OnGpuMemoryUmaStatsReceived)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped(message))
#endif
IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel,
OnDestroyChannel)
......@@ -844,68 +850,46 @@ void GpuProcessHost::OnGpuMemoryUmaStatsReceived(
}
#if defined(OS_MACOSX)
void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped");
namespace {
void HoldIOSurfaceReference(base::ScopedCFTypeRef<IOSurfaceRef> io_surface) {}
} // namespace
if (!ui::LatencyInfo::Verify(params.latency_info,
"GpuHostMsg_AcceleratedSurfaceBuffersSwapped"))
return;
void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
const IPC::Message& message) {
RenderWidgetResizeHelper::Get()->PostGpuProcessMsg(host_id_, message);
gfx::AcceleratedWidget native_widget =
GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id);
if (native_widget) {
RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread(this, params);
if (!IsDelegatedRendererEnabled())
return;
}
gfx::GLSurfaceHandle surface_handle =
GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id);
// Compositor window is always gfx::kNullPluginWindow.
// TODO(jbates) http://crbug.com/105344 This will be removed when there are no
// plugin windows.
if (surface_handle.handle != gfx::kNullPluginWindow ||
surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) {
RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
GpuHostMsg_AcceleratedSurfaceBuffersSwapped::Param param;
if (!GpuHostMsg_AcceleratedSurfaceBuffersSwapped::Read(&message, &param))
return;
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params = param.a;
if (GetSurfaceHandleType(params.surface_handle) ==
kSurfaceHandleTypeIOSurface) {
// As soon as the frame is acked, the IOSurface may be thrown away by the
// GPU process. Open the IOSurface and post a task referencing it to the UI
// thread. This will keep the IOSurface from being thrown away until the UI
// thread can open another reference to it, if needed.
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(
IOSurfaceIDFromSurfaceHandle(params.surface_handle)));
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(HoldIOSurfaceReference, io_surface));
}
// If delegated rendering is enabled, then immediately acknowledge this frame
// on the IO thread instead of the UI thread. The UI thread will wait on the
// GPU process. If the UI thread were to be responsible for acking swaps,
// then there would be a cycle and a potential deadlock. Back-pressure from
// the GPU is provided through the compositor's output surface.
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
ack_params.sync_point = 0;
int render_process_id = 0;
int render_widget_id = 0;
if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface(
params.surface_id, &render_process_id, &render_widget_id)) {
Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
ack_params));
return;
}
RenderWidgetHelper* helper =
RenderWidgetHelper::FromProcessHostID(render_process_id);
if (!helper) {
Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
ack_params));
return;
}
// Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread
// if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper
// will forward to the RenderWidgetHostView via RenderProcessHostImpl and
// RenderWidgetHostImpl.
ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params;
view_params.surface_id = params.surface_id;
view_params.surface_handle = params.surface_handle;
view_params.route_id = params.route_id;
view_params.size = params.size;
view_params.scale_factor = params.scale_factor;
view_params.gpu_process_host_id = host_id_;
view_params.latency_info = params.latency_info;
helper->DidReceiveBackingStoreMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped(
render_widget_id,
view_params));
ack_params.renderer_id = 0;
Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params));
}
#endif // OS_MACOSX
#endif
void GpuProcessHost::OnProcessLaunched() {
UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime",
......
......@@ -31,9 +31,6 @@
#include "url/gurl.h"
struct GPUCreateCommandBufferConfig;
struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
struct GpuHostMsg_AcceleratedSurfaceRelease_Params;
namespace gfx {
struct GpuMemoryBufferHandle;
......@@ -185,8 +182,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void OnDidDestroyOffscreenContext(const GURL& url);
void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats);
#if defined(OS_MACOSX)
void OnAcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message);
#endif
void CreateChannelCache(int32 client_id);
......
......@@ -11,11 +11,13 @@
#include "base/id_map.h"
#include "base/lazy_instance.h"
#include "base/strings/string_number_conversions.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/public/browser/browser_thread.h"
......@@ -254,6 +256,16 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
if (!ui::LatencyInfo::Verify(params.latency_info,
"GpuHostMsg_AcceleratedSurfaceBuffersSwapped"))
return;
#if defined(OS_MACOSX)
// On Mac with delegated rendering, accelerated surfaces are swapped by
// calling a method on their NSView.
if (IsDelegatedRendererEnabled()) {
RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread(params);
return;
}
#endif
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
ack_params.mailbox = params.mailbox;
ack_params.sync_point = 0;
......
......@@ -29,6 +29,7 @@
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/renderer_host/render_widget_resize_helper.h"
#include "content/browser/transition_request_manager.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/child_process_messages.h"
......@@ -404,10 +405,14 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToPpapiBroker,
OnOpenChannelToPpapiBroker)
#endif
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame,
render_widget_helper_->DidReceiveBackingStoreMsg(message))
RenderWidgetResizeHelper::Get()->PostRendererProcessMsg(
render_process_id_, message))
IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_UpdateRect,
render_widget_helper_->DidReceiveBackingStoreMsg(message))
RenderWidgetResizeHelper::Get()->PostRendererProcessMsg(
render_process_id_, message))
#endif
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_CheckPermission,
OnCheckNotificationPermission)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
......
......@@ -950,19 +950,6 @@ void RenderProcessHostImpl::RemoveObserver(
observers_.RemoveObserver(observer);
}
bool RenderProcessHostImpl::WaitForBackingStoreMsg(
int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) {
// The post task to this thread with the process id could be in queue, and we
// don't want to dispatch a message before then since it will need the handle.
if (child_process_launcher_.get() && child_process_launcher_->IsStarting())
return false;
return widget_helper_->WaitForBackingStoreMsg(render_widget_id,
max_delay, msg);
}
void RenderProcessHostImpl::ReceivedBadMessage() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC))
......@@ -1405,13 +1392,6 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
reply->set_reply_error();
Send(reply);
}
// If this is a SwapBuffers, we need to ack it if we're not going to handle
// it so that the GPU process doesn't get stuck in unscheduled state.
IPC_BEGIN_MESSAGE_MAP(RenderProcessHostImpl, msg)
IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped,
OnCompositorSurfaceBuffersSwappedNoHost)
IPC_END_MESSAGE_MAP()
return true;
}
return listener->OnMessageReceived(msg);
......@@ -2142,20 +2122,6 @@ void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size);
}
void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost(
const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) {
TRACE_EVENT0("renderer_host",
"RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost");
if (!ui::LatencyInfo::Verify(params.latency_info,
"ViewHostMsg_CompositorSurfaceBuffersSwapped"))
return;
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
ack_params.sync_point = 0;
RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id,
params.gpu_process_host_id,
ack_params);
}
void RenderProcessHostImpl::OnGpuSwitching() {
// We are updating all widgets including swapped out ones.
scoped_ptr<RenderWidgetHostIterator> widgets(
......
......@@ -30,8 +30,6 @@
#include "base/mac/scoped_cftyperef.h"
#endif
struct ViewHostMsg_CompositorSurfaceBuffersSwapped_Params;
namespace base {
class CommandLine;
class MessageLoop;
......@@ -99,9 +97,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
virtual void RemoveRoute(int32 routing_id) OVERRIDE;
virtual void AddObserver(RenderProcessHostObserver* observer) OVERRIDE;
virtual void RemoveObserver(RenderProcessHostObserver* observer) OVERRIDE;
virtual bool WaitForBackingStoreMsg(int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) OVERRIDE;
virtual void ReceivedBadMessage() OVERRIDE;
virtual void WidgetRestored() OVERRIDE;
virtual void WidgetHidden() OVERRIDE;
......@@ -295,10 +290,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
void OnSavedPageAsMHTML(int job_id, int64 mhtml_file_size);
void OnCloseACK(int old_route_id);
// CompositorSurfaceBuffersSwapped handler when there's no RWH.
void OnCompositorSurfaceBuffersSwappedNoHost(
const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params);
// Generates a command line to be used to spawn a renderer and appends the
// results to |*command_line|.
void AppendRendererCommandLine(base::CommandLine* command_line) const;
......
......@@ -10,6 +10,7 @@
#include "base/posix/eintr_wrapper.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
......@@ -34,53 +35,8 @@ void AddWidgetHelper(int render_process_id,
} // namespace
// A helper used with DidReceiveBackingStoreMsg that we hold a pointer to in
// pending_paints_.
class RenderWidgetHelper::BackingStoreMsgProxy {
public:
BackingStoreMsgProxy(RenderWidgetHelper* h, const IPC::Message& m);
~BackingStoreMsgProxy();
void Run();
void Cancel() { cancelled_ = true; }
const IPC::Message& message() const { return message_; }
private:
scoped_refptr<RenderWidgetHelper> helper_;
IPC::Message message_;
bool cancelled_; // If true, then the message will not be dispatched.
DISALLOW_COPY_AND_ASSIGN(BackingStoreMsgProxy);
};
RenderWidgetHelper::BackingStoreMsgProxy::BackingStoreMsgProxy(
RenderWidgetHelper* h, const IPC::Message& m)
: helper_(h),
message_(m),
cancelled_(false) {
}
RenderWidgetHelper::BackingStoreMsgProxy::~BackingStoreMsgProxy() {
// If the paint message was never dispatched, then we need to let the
// helper know that we are going away.
if (!cancelled_ && helper_.get())
helper_->OnDiscardBackingStoreMsg(this);
}
void RenderWidgetHelper::BackingStoreMsgProxy::Run() {
if (!cancelled_) {
helper_->OnDispatchBackingStoreMsg(this);
helper_ = NULL;
}
}
RenderWidgetHelper::RenderWidgetHelper()
: render_process_id_(-1),
#if defined(OS_WIN)
event_(CreateEvent(NULL, FALSE /* auto-reset */, FALSE, NULL)),
#elif defined(OS_POSIX)
event_(false /* auto-reset */, false),
#endif
resource_dispatcher_host_(NULL) {
}
......@@ -93,10 +49,6 @@ RenderWidgetHelper::~RenderWidgetHelper() {
if (it != widget_map.end() && it->second == this)
widget_map.erase(it);
// The elements of pending_paints_ each hold an owning reference back to this
// object, so we should not be destroyed unless pending_paints_ is empty!
DCHECK(pending_paints_.empty());
#if defined(OS_POSIX) && !defined(OS_ANDROID)
ClearAllocatedDIBs();
#endif
......@@ -146,51 +98,6 @@ void RenderWidgetHelper::ResumeResponseDeferredAtStart(
request_id));
}
bool RenderWidgetHelper::WaitForBackingStoreMsg(
int render_widget_id, const base::TimeDelta& max_delay, IPC::Message* msg) {
base::TimeTicks time_start = base::TimeTicks::Now();
for (;;) {
BackingStoreMsgProxy* proxy = NULL;
{
base::AutoLock lock(pending_paints_lock_);
BackingStoreMsgProxyMap::iterator it =
pending_paints_.find(render_widget_id);
if (it != pending_paints_.end()) {
BackingStoreMsgProxyQueue &queue = it->second;
DCHECK(!queue.empty());
proxy = queue.front();
// Flag the proxy as cancelled so that when it is run as a task it will
// do nothing.
proxy->Cancel();
queue.pop_front();
if (queue.empty())
pending_paints_.erase(it);
}
}
if (proxy) {
*msg = proxy->message();
DCHECK(msg->routing_id() == render_widget_id);
return true;
}
// Calculate the maximum amount of time that we are willing to sleep.
base::TimeDelta max_sleep_time =
max_delay - (base::TimeTicks::Now() - time_start);
if (max_sleep_time <= base::TimeDelta::FromMilliseconds(0))
break;
base::ThreadRestrictions::ScopedAllowWait allow_wait;
event_.TimedWait(max_sleep_time);
}
return false;
}
void RenderWidgetHelper::ResumeRequestsForView(int route_id) {
// We only need to resume blocked requests if we used a valid route_id.
// See CreateNewWindow.
......@@ -202,54 +109,6 @@ void RenderWidgetHelper::ResumeRequestsForView(int route_id) {
}
}
void RenderWidgetHelper::DidReceiveBackingStoreMsg(const IPC::Message& msg) {
int render_widget_id = msg.routing_id();
BackingStoreMsgProxy* proxy = new BackingStoreMsgProxy(this, msg);
{
base::AutoLock lock(pending_paints_lock_);
pending_paints_[render_widget_id].push_back(proxy);
}
// Notify anyone waiting on the UI thread that there is a new entry in the
// proxy map. If they don't find the entry they are looking for, then they
// will just continue waiting.
event_.Signal();
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&BackingStoreMsgProxy::Run, base::Owned(proxy)));
}
void RenderWidgetHelper::OnDiscardBackingStoreMsg(BackingStoreMsgProxy* proxy) {
const IPC::Message& msg = proxy->message();
// Remove the proxy from the map now that we are going to handle it normally.
{
base::AutoLock lock(pending_paints_lock_);
BackingStoreMsgProxyMap::iterator it =
pending_paints_.find(msg.routing_id());
DCHECK(it != pending_paints_.end());
BackingStoreMsgProxyQueue &queue = it->second;
DCHECK(queue.front() == proxy);
queue.pop_front();
if (queue.empty())
pending_paints_.erase(it);
}
}
void RenderWidgetHelper::OnDispatchBackingStoreMsg(
BackingStoreMsgProxy* proxy) {
OnDiscardBackingStoreMsg(proxy);
// It is reasonable for the host to no longer exist.
RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
if (host)
host->OnMessageReceived(proxy->message());
}
void RenderWidgetHelper::OnResumeDeferredNavigation(
const GlobalRequestID& request_id) {
resource_dispatcher_host_->ResumeDeferredNavigation(request_id);
......
......@@ -5,15 +5,12 @@
#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HELPER_H_
#include <deque>
#include <map>
#include "base/atomic_sequence_num.h"
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "base/process/process.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/global_request_id.h"
......@@ -45,38 +42,6 @@ class SessionStorageNamespace;
// the RenderWidgetHost lives.
//
//
// OPTIMIZED RESIZE
//
// RenderWidgetHelper is used to implement optimized resize. When the
// RenderWidgetHost is resized, it sends a Resize message to its RenderWidget
// counterpart in the renderer process. In response to the Resize message,
// the RenderWidget generates a new BackingStore and sends an UpdateRect
// message (or BuffersSwapped via the GPU process in the case of accelerated
// compositing), and it sets the IS_RESIZE_ACK flag in the UpdateRect message
// to true. In the accelerated case, an UpdateRect is still sent from the
// renderer to the browser with acks and plugin moves even though the GPU
// BackingStore was sent earlier in the BuffersSwapped message. "BackingStore
// message" is used throughout this code and documentation to mean either a
// software UpdateRect or GPU BuffersSwapped message.
//
// Back in the browser process, when the RenderProcessHost's MessageFilter
// sees an UpdateRect message (or when the GpuProcessHost sees a
// BuffersSwapped message), it directs it to the RenderWidgetHelper by calling
// the DidReceiveBackingStoreMsg method. That method stores the data for the
// message in a map, where it can be directly accessed by the RenderWidgetHost
// on the UI thread during a call to RenderWidgetHost's GetBackingStore
// method.
//
// When the RenderWidgetHost's GetBackingStore method is called, it first
// checks to see if it is waiting for a resize ack. If it is, then it calls
// the RenderWidgetHelper's WaitForBackingStoreMsg to check if there is
// already a resulting BackingStore message (or to wait a short amount of time
// for one to arrive). The main goal of this mechanism is to short-cut the
// usual way in which IPC messages are proxied over to the UI thread via
// InvokeLater. This approach is necessary since window resize is followed up
// immediately by a request to repaint the window.
//
//
// OPTIMIZED TAB SWITCHING
//
// When a RenderWidgetHost is in a background tab, it is flagged as hidden.
......@@ -104,6 +69,7 @@ class SessionStorageNamespace;
// allocation and maintains the set of allocated transport DIBs which the
// renderers can refer to.
//
class RenderWidgetHelper
: public base::RefCountedThreadSafe<RenderWidgetHelper,
BrowserThread::DeleteOnIOThread> {
......@@ -130,17 +96,17 @@ class RenderWidgetHelper
// for documentation.
void ResumeDeferredNavigation(const GlobalRequestID& request_id);
void ResumeResponseDeferredAtStart(const GlobalRequestID& request_id);
bool WaitForBackingStoreMsg(int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg);
// Called to resume the requests for a view after it's ready. The view was
// created by CreateNewWindow which initially blocked the requests.
void ResumeRequestsForView(int route_id);
// IO THREAD ONLY -----------------------------------------------------------
#if defined(OS_MACOSX)
static void OnNativeSurfaceBuffersSwappedOnUIThread(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
#endif
// Called on the IO thread when a BackingStore message is received.
void DidReceiveBackingStoreMsg(const IPC::Message& msg);
// IO THREAD ONLY -----------------------------------------------------------
void CreateNewWindow(
const ViewHostMsg_CreateWindow_Params& params,
......@@ -170,34 +136,13 @@ class RenderWidgetHelper
void FreeTransportDIB(TransportDIB::Id dib_id);
#endif
#if defined(OS_MACOSX)
static void OnNativeSurfaceBuffersSwappedOnIOThread(
GpuProcessHost* gpu_process_host,
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
#endif
private:
// A class used to proxy a paint message. PaintMsgProxy objects are created
// on the IO thread and destroyed on the UI thread.
class BackingStoreMsgProxy;
friend class BackingStoreMsgProxy;
friend class base::RefCountedThreadSafe<RenderWidgetHelper>;
friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
friend class base::DeleteHelper<RenderWidgetHelper>;
typedef std::deque<BackingStoreMsgProxy*> BackingStoreMsgProxyQueue;
// Map from render_widget_id to a queue of live PaintMsgProxy instances.
typedef base::hash_map<int, BackingStoreMsgProxyQueue >
BackingStoreMsgProxyMap;
~RenderWidgetHelper();
// Called on the UI thread to discard a paint message.
void OnDiscardBackingStoreMsg(BackingStoreMsgProxy* proxy);
// Called on the UI thread to dispatch a paint message if necessary.
void OnDispatchBackingStoreMsg(BackingStoreMsgProxy* proxy);
// Called on the UI thread to finish creating a window.
void OnCreateWindowOnUI(
const ViewHostMsg_CreateWindow_Params& params,
......@@ -234,18 +179,8 @@ class RenderWidgetHelper
std::map<TransportDIB::Id, int> allocated_dibs_;
#endif
// A map of live paint messages. Must hold pending_paints_lock_ to access.
// The BackingStoreMsgProxy objects are not owned by this map. (See
// BackingStoreMsgProxy for details about how the lifetime of instances are
// managed.)
BackingStoreMsgProxyMap pending_paints_;
base::Lock pending_paints_lock_;
int render_process_id_;
// Event used to implement WaitForBackingStoreMsg.
base::WaitableEvent event_;
// The next routing id to use.
base::AtomicSequenceNumber next_routing_id_;
......
......@@ -14,10 +14,10 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/surface_handle_types_mac.h"
namespace {
namespace content {
void OnNativeSurfaceBuffersSwappedOnUIThread(
base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
// static
void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
gfx::AcceleratedWidget native_widget =
......@@ -31,36 +31,4 @@ void OnNativeSurfaceBuffersSwappedOnUIThread(
withScaleFactor:params.scale_factor];
}
} // namespace
namespace content {
void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread(
GpuProcessHost* gpu_process_host,
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Immediately acknowledge this frame on the IO thread instead of the UI
// thread. The UI thread will wait on the GPU process. If the UI thread
// were to be responsible for acking swaps, then there would be a cycle
// and a potential deadlock.
// TODO(ccameron): This immediate ack circumvents GPU back-pressure that
// is necessary to throttle renderers. Fix that.
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
ack_params.sync_point = 0;
ack_params.renderer_id = 0;
gpu_process_host->Send(new AcceleratedSurfaceMsg_BufferPresented(
params.route_id, ack_params));
// Open the IOSurface handle before returning, to ensure that it is not
// closed as soon as the frame is acknowledged.
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(
static_cast<uint32>(params.surface_handle)));
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&OnNativeSurfaceBuffersSwappedOnUIThread, io_surface, params));
}
} // namespace content
......@@ -44,6 +44,7 @@
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/render_widget_resize_helper.h"
#include "content/common/accessibility_messages.h"
#include "content/common/content_constants_internal.h"
#include "content/common/cursors/webcursor.h"
......@@ -89,12 +90,6 @@ namespace {
bool g_check_for_pending_resize_ack = true;
// How long to (synchronously) wait for the renderer to respond with a
// PaintRect message, when our backing-store is invalid, before giving up and
// returning a null or incorrectly sized backing-store from GetBackingStore.
// This timeout impacts the "choppiness" of our window resize perf.
const int kPaintMsgTimeoutMS = 50;
typedef std::pair<int32, int32> RenderWidgetHostID;
typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*>
RoutingIDWidgetMap;
......@@ -476,10 +471,6 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed,
OnWindowlessPluginDummyWindowDestroyed)
#endif
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped,
OnCompositorSurfaceBuffersSwapped)
#endif
#if defined(OS_MACOSX) || defined(USE_AURA)
IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
OnImeCompositionRangeChanged)
......@@ -710,6 +701,7 @@ void RenderWidgetHostImpl::UnlockBackingStore() {
}
#endif
#if defined(OS_MACOSX)
void RenderWidgetHostImpl::PauseForPendingResizeOrRepaints() {
TRACE_EVENT0("browser",
"RenderWidgetHostImpl::PauseForPendingResizeOrRepaints");
......@@ -735,6 +727,11 @@ bool RenderWidgetHostImpl::CanPauseForPendingResizeOrRepaints() {
void RenderWidgetHostImpl::WaitForSurface() {
TRACE_EVENT0("browser", "RenderWidgetHostImpl::WaitForSurface");
// How long to (synchronously) wait for the renderer to respond with a
// new frame when our current frame doesn't exist or is the wrong size.
// This timeout impacts the "choppiness" of our window resize.
const int kPaintMsgTimeoutMS = 50;
if (!view_)
return;
......@@ -792,8 +789,7 @@ void RenderWidgetHostImpl::WaitForSurface() {
// on a response, block for a little while to see if we can't get a response
// before returning the old (incorrectly sized) backing store.
IPC::Message msg;
if (process_->WaitForBackingStoreMsg(routing_id_, max_delay, &msg)) {
OnMessageReceived(msg);
if (RenderWidgetResizeHelper::Get()->WaitForSingleTaskToRun(max_delay)) {
// For auto-resized views, current_size_ determines the view_size and it
// may have changed during the handling of an UpdateRect message.
......@@ -816,6 +812,7 @@ void RenderWidgetHostImpl::WaitForSurface() {
max_delay = end_time - TimeTicks::Now();
} while (max_delay > TimeDelta::FromSeconds(0));
}
#endif
bool RenderWidgetHostImpl::ScheduleComposite() {
if (is_hidden_ || current_size_.IsEmpty() || repaint_ack_pending_ ||
......@@ -1413,43 +1410,6 @@ void RenderWidgetHostImpl::OnRequestMove(const gfx::Rect& pos) {
}
}
#if defined(OS_MACOSX)
void RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwapped(
const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) {
// This trace event is used in
// chrome/browser/extensions/api/cast_streaming/performance_test.cc
TRACE_EVENT0("renderer_host",
"RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwapped");
// This trace event is used in
// chrome/browser/extensions/api/cast_streaming/performance_test.cc
UNSHIPPED_TRACE_EVENT0("test_fps",
TRACE_DISABLED_BY_DEFAULT("OnSwapCompositorFrame"));
if (!ui::LatencyInfo::Verify(params.latency_info,
"ViewHostMsg_CompositorSurfaceBuffersSwapped"))
return;
if (!view_) {
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
ack_params.sync_point = 0;
RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id,
params.gpu_process_host_id,
ack_params);
return;
}
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params;
gpu_params.surface_id = params.surface_id;
gpu_params.surface_handle = params.surface_handle;
gpu_params.route_id = params.route_id;
gpu_params.size = params.size;
gpu_params.scale_factor = params.scale_factor;
gpu_params.latency_info = params.latency_info;
for (size_t i = 0; i < gpu_params.latency_info.size(); i++)
AddLatencyInfoComponentIds(&gpu_params.latency_info[i]);
view_->AcceleratedSurfaceBuffersSwapped(gpu_params,
params.gpu_process_host_id);
view_->DidReceiveRendererFrame();
}
#endif // OS_MACOSX
bool RenderWidgetHostImpl::OnSwapCompositorFrame(
const IPC::Message& message) {
// This trace event is used in
......
......@@ -43,7 +43,6 @@
struct AcceleratedSurfaceMsg_BufferPresented_Params;
struct ViewHostMsg_BeginSmoothScroll_Params;
struct ViewHostMsg_CompositorSurfaceBuffersSwapped_Params;
struct ViewHostMsg_SelectionBounds_Params;
struct ViewHostMsg_TextInputState_Params;
struct ViewHostMsg_UpdateRect_Params;
......@@ -253,6 +252,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// Indicates if the page has finished loading.
void SetIsLoading(bool is_loading);
#if defined(OS_MACOSX)
// Pause for a moment to wait for pending repaint or resize messages sent to
// the renderer to arrive. If pending resize messages are for an old window
// size, then also pump through a new resize message if there is time.
......@@ -261,11 +261,12 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// Whether pausing may be useful.
bool CanPauseForPendingResizeOrRepaints();
bool resize_ack_pending_for_testing() { return resize_ack_pending_; }
// Wait for a surface matching the size of the widget's view, possibly
// blocking until the renderer sends a new frame.
void WaitForSurface();
#endif
bool resize_ack_pending_for_testing() { return resize_ack_pending_; }
// GPU accelerated version of GetBackingStore function. This will
// trigger a re-composite to the view. It may fail if a resize is pending, or
......@@ -622,10 +623,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl
void OnRequestMove(const gfx::Rect& pos);
void OnSetTooltipText(const base::string16& tooltip_text,
blink::WebTextDirection text_direction_hint);
#if defined(OS_MACOSX)
void OnCompositorSurfaceBuffersSwapped(
const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params);
#endif
bool OnSwapCompositorFrame(const IPC::Message& message);
void OnFlingingStopped();
void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params);
......
......@@ -202,15 +202,11 @@ class RenderWidgetHostProcess : public MockRenderProcessHost {
public:
explicit RenderWidgetHostProcess(BrowserContext* browser_context)
: MockRenderProcessHost(browser_context),
update_msg_should_reply_(false),
update_msg_reply_flags_(0) {
}
virtual ~RenderWidgetHostProcess() {
}
void set_update_msg_should_reply(bool reply) {
update_msg_should_reply_ = reply;
}
void set_update_msg_reply_flags(int flags) {
update_msg_reply_flags_ = flags;
}
......@@ -221,14 +217,6 @@ class RenderWidgetHostProcess : public MockRenderProcessHost {
virtual bool HasConnection() const OVERRIDE { return true; }
protected:
virtual bool WaitForBackingStoreMsg(int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) OVERRIDE;
// Set to true when WaitForBackingStoreMsg should return a successful update
// message reply. False implies timeout.
bool update_msg_should_reply_;
// Indicates the flags that should be sent with a repaint request. This
// only has an effect when update_msg_should_reply_ is true.
int update_msg_reply_flags_;
......@@ -244,22 +232,6 @@ void RenderWidgetHostProcess::InitUpdateRectParams(
params->flags = update_msg_reply_flags_;
}
bool RenderWidgetHostProcess::WaitForBackingStoreMsg(
int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) {
if (!update_msg_should_reply_)
return false;
// Construct a fake update reply.
ViewHostMsg_UpdateRect_Params params;
InitUpdateRectParams(&params);
ViewHostMsg_UpdateRect message(render_widget_id, params);
*msg = message;
return true;
}
// TestView --------------------------------------------------------------------
// This test view allows us to specify the size, and keep track of acked
......
// 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_resize_helper.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/public/browser/browser_thread.h"
namespace content {
namespace {
base::LazyInstance<RenderWidgetResizeHelper> g_render_widget_task_runner =
LAZY_INSTANCE_INITIALIZER;
} // namespace
// A wrapper for IPCs and tasks that we may potentially execute in
// WaitForSingleTaskToRun. Because these tasks are sent to two places to run,
// we to wrap them in this structure and track whether or not they have run
// yet, to avoid running them twice.
class RenderWidgetResizeHelper::EnqueuedTask {
public:
enum Type {
RENDERER_IPC,
GPU_IPC,
};
EnqueuedTask(Type type, int process_id, const IPC::Message& m);
~EnqueuedTask();
void Run();
void InvalidateHelper();
private:
Type type_;
int process_id_;
IPC::Message message_;
bool has_run_;
RenderWidgetResizeHelper* helper_;
DISALLOW_COPY_AND_ASSIGN(EnqueuedTask);
};
RenderWidgetResizeHelper::EnqueuedTask::EnqueuedTask(
Type type,
int process_id,
const IPC::Message& m)
: type_(type),
process_id_(process_id),
message_(m),
has_run_(false),
helper_(RenderWidgetResizeHelper::Get()) {
}
RenderWidgetResizeHelper::EnqueuedTask::~EnqueuedTask() {
}
void RenderWidgetResizeHelper::EnqueuedTask::Run() {
if (has_run_)
return;
if (helper_)
helper_->WillRunEnqueuedTask(this);
has_run_ = true;
switch (type_) {
case RENDERER_IPC: {
RenderProcessHost* host = RenderProcessHost::FromID(process_id_);
if (host)
host->OnMessageReceived(message_);
break;
}
case GPU_IPC: {
GpuProcessHostUIShim* host = GpuProcessHostUIShim::FromID(process_id_);
if (host)
host->OnMessageReceived(message_);
break;
}
}
}
void RenderWidgetResizeHelper::EnqueuedTask::InvalidateHelper() {
helper_ = NULL;
}
// static
RenderWidgetResizeHelper* RenderWidgetResizeHelper::Get() {
return g_render_widget_task_runner.Pointer();
}
bool RenderWidgetResizeHelper::WaitForSingleTaskToRun(
const base::TimeDelta& max_delay) {
base::TimeTicks time_start = base::TimeTicks::Now();
for (;;) {
// Peek at the message from the front of the queue. Running it will remove
// it from the queue.
EnqueuedTask* task = NULL;
{
base::AutoLock lock(task_queue_lock_);
if (!task_queue_.empty())
task = task_queue_.front();
}
if (task) {
task->Run();
return true;
}
// Calculate the maximum amount of time that we are willing to sleep.
base::TimeDelta max_sleep_time =
max_delay - (base::TimeTicks::Now() - time_start);
if (max_sleep_time <= base::TimeDelta::FromMilliseconds(0))
break;
base::ThreadRestrictions::ScopedAllowWait allow_wait;
event_.TimedWait(max_sleep_time);
}
return false;
}
void RenderWidgetResizeHelper::PostEnqueuedTask(EnqueuedTask* task) {
{
base::AutoLock lock(task_queue_lock_);
task_queue_.push_back(task);
}
// Notify anyone waiting on the UI thread that there is a new entry in the
// task map. If they don't find the entry they are looking for, then they
// will just continue waiting.
event_.Signal();
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&EnqueuedTask::Run, base::Owned(task)));
}
void RenderWidgetResizeHelper::WillRunEnqueuedTask(EnqueuedTask* task) {
base::AutoLock lock(task_queue_lock_);
DCHECK(task_queue_.front() == task);
task_queue_.pop_front();
}
void RenderWidgetResizeHelper::PostRendererProcessMsg(
int render_process_id, const IPC::Message& msg) {
PostEnqueuedTask(new EnqueuedTask(
EnqueuedTask::RENDERER_IPC, render_process_id, msg));
}
void RenderWidgetResizeHelper::PostGpuProcessMsg(
int gpu_host_id, const IPC::Message& msg) {
PostEnqueuedTask(new EnqueuedTask(EnqueuedTask::GPU_IPC, gpu_host_id, msg));
}
RenderWidgetResizeHelper::RenderWidgetResizeHelper()
: event_(false /* auto-reset */, false /* initially signalled */) {}
RenderWidgetResizeHelper::~RenderWidgetResizeHelper() {
// Ensure that any tasks that outlive this do not reach back into it.
for (EnqueuedTaskQueue::iterator it = task_queue_.begin();
it != task_queue_.end(); ++it) {
EnqueuedTask* task = *it;
task->InvalidateHelper();
}
}
} // namespace content
// 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_RESIZE_HELPER_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_RESIZE_HELPER_H_
#include <deque>
#include "base/lazy_instance.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "ipc/ipc_message.h"
namespace content {
// RenderWidgetResizeHelper is used to make resize appear smooth. That is to
// say, make sure that the window size and the size of the content being drawn
// in that window are resized in lock-step. This is accomplished by waiting
// inside -[RenderWidgetHostViewCocoa setFrameSize:] for the renderer (and
// potentially browser compositor as well) to produce a frame of same size
// as the RenderWidgetHostViewCocoa.
//
// The function of waiting for a frame of the correct size is done inside
// RenderWidgetHostImpl::WaitForSurface. That function will call
// RenderWidgetResizeHelper::WaitForSingleTaskToRun until a timeout occurs,
// or the corresponding RenderWidgetHostViewCocoa has a renderer frame of the
// same size as its NSView.
//
// This is somewhat complicated because waiting for frames requires that
// that the browser handle the IPCs (from the renderer and the GPU processes)
// that are required to pick up a new frame. In the ordinary run of things
// (ignoring RenderWidgetResizeHelper), those IPCs arrive on the IO thread
// and are posted as tasks to the UI thread either by the RenderMessageFilter
// (for renderer processes) or the GpuProcessHostUIShim (for the GPU process).
// The IPCs that are required to create new frames for smooth resize are sent
// to the RenderWidgetResizeHelper using the PostRendererProcessMsg and
// PostGpuProcessMsg methods. These functions will post them as tasks to the UI
// thread (as usual), and will also enqueue them into a queue which will be
// read and run in RenderWidgetResizeHelper::WaitForSingleTaskToRun, potentially
// before the task posted to the UI thread is run. Some care is taken (see
// EnqueuedTask) to make sure that the messages are only executed once.
//
// TODO(ccameron): This does not support smooth resize when using the
// ui::Compositor yet. To support this, it will be necessary that the
// RenderWidgetResizeHelper have a base::TaskRunner to send to the
// cc::ThreadProxy. The tasks that cc then posts can be pumped in
// WaitForSingleTaskToRun in a way similar to the one in which IPCs are handled.
//
class RenderWidgetResizeHelper {
public:
static RenderWidgetResizeHelper* Get();
// UI THREAD ONLY -----------------------------------------------------------
// Waits at most |max_delay| for a task to run. Returns true if a task ran,
// false if no task ran.
bool WaitForSingleTaskToRun(const base::TimeDelta& max_delay);
// IO THREAD ONLY -----------------------------------------------------------
// This will cause |msg| to be handled by the RenderProcessHost corresponding
// to |render_process_id|, on the UI thread. This will either happen when the
// ordinary message loop would run it, or potentially earlier in a call to
// WaitForSingleTaskToRun .
void PostRendererProcessMsg(int render_process_id, const IPC::Message& msg);
// This is similar to PostRendererProcessMsg, but will handle the message in
// the GpuProcessHostUIShim corresponding to |gpu_host_id|.
void PostGpuProcessMsg(int gpu_host_id, const IPC::Message& msg);
private:
friend struct base::DefaultLazyInstanceTraits<RenderWidgetResizeHelper>;
RenderWidgetResizeHelper();
~RenderWidgetResizeHelper();
// A classed used to wrap an IPC or a task.
class EnqueuedTask;
friend class EnqueuedTask;
// Called on the IO thread to add a task to the queue.
void PostEnqueuedTask(EnqueuedTask* proxy);
// Called on the UI to remove the task from the queue when it is run.
void WillRunEnqueuedTask(EnqueuedTask* proxy);
// A queue of live messages. Must hold |task_queue_lock_| to access.
// The EnqueuedTask objects are removed from the front of the queue when
// they are run (either by TaskRunner they were posted to or by a call to
// WaitForSingleTaskToRun pulling them off of the queue).
typedef std::deque<EnqueuedTask*> EnqueuedTaskQueue;
EnqueuedTaskQueue task_queue_;
base::Lock task_queue_lock_;
// Event used to wake up the UI thread if it is sleeping in
// WaitForSingleTaskToRun.
base::WaitableEvent event_;
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_RESIZE_HELPER_H_
......@@ -1441,23 +1441,6 @@ IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateZoomLimits,
IPC_MESSAGE_CONTROL1(ViewHostMsg_SuddenTerminationChanged,
bool /* enabled */)
IPC_STRUCT_BEGIN(ViewHostMsg_CompositorSurfaceBuffersSwapped_Params)
IPC_STRUCT_MEMBER(int32, surface_id)
IPC_STRUCT_MEMBER(uint64, surface_handle)
IPC_STRUCT_MEMBER(int32, route_id)
IPC_STRUCT_MEMBER(gfx::Size, size)
IPC_STRUCT_MEMBER(float, scale_factor)
IPC_STRUCT_MEMBER(int32, gpu_process_host_id)
IPC_STRUCT_MEMBER(std::vector<ui::LatencyInfo>, latency_info)
IPC_STRUCT_END()
// This message is synthesized by GpuProcessHost to pass through a swap message
// to the RenderWidgetHelper. This allows GetBackingStore to block for either a
// software or GPU frame.
IPC_MESSAGE_ROUTED1(
ViewHostMsg_CompositorSurfaceBuffersSwapped,
ViewHostMsg_CompositorSurfaceBuffersSwapped_Params /* params */)
IPC_MESSAGE_ROUTED2(ViewHostMsg_SwapCompositorFrame,
uint32 /* output_surface_id */,
cc::CompositorFrame /* frame */)
......
......@@ -1060,6 +1060,8 @@
'browser/renderer_host/render_widget_host_view_mac_editcommand_helper.mm',
'browser/renderer_host/render_widget_host_view_mac.h',
'browser/renderer_host/render_widget_host_view_mac.mm',
'browser/renderer_host/render_widget_resize_helper.cc',
'browser/renderer_host/render_widget_resize_helper.h',
'browser/renderer_host/renderer_frame_manager.cc',
'browser/renderer_host/renderer_frame_manager.h',
'browser/renderer_host/sandbox_ipc_linux.cc',
......
......@@ -80,13 +80,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender,
virtual void AddObserver(RenderProcessHostObserver* observer) = 0;
virtual void RemoveObserver(RenderProcessHostObserver* observer) = 0;
// Called to wait for the next UpdateRect message for the specified render
// widget. Returns true if successful, and the msg out-param will contain a
// copy of the received UpdateRect message.
virtual bool WaitForBackingStoreMsg(int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) = 0;
// Called when a received message cannot be decoded.
virtual void ReceivedBadMessage() = 0;
......
......@@ -80,13 +80,6 @@ void MockRenderProcessHost::RemoveObserver(
observers_.RemoveObserver(observer);
}
bool MockRenderProcessHost::WaitForBackingStoreMsg(
int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) {
return false;
}
void MockRenderProcessHost::ReceivedBadMessage() {
++bad_msg_count_;
}
......
......@@ -40,9 +40,6 @@ class MockRenderProcessHost : public RenderProcessHost {
virtual void RemoveRoute(int32 routing_id) OVERRIDE;
virtual void AddObserver(RenderProcessHostObserver* observer) OVERRIDE;
virtual void RemoveObserver(RenderProcessHostObserver* observer) OVERRIDE;
virtual bool WaitForBackingStoreMsg(int render_widget_id,
const base::TimeDelta& max_delay,
IPC::Message* msg) OVERRIDE;
virtual void ReceivedBadMessage() OVERRIDE;
virtual void WidgetRestored() OVERRIDE;
virtual void WidgetHidden() OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment