Index: content/common/gpu/client/gpu_channel_host.cc |
diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc |
index f7f5d823eedb84285f08f16f93c8b609bcd80793..b7087379e79b740485499c94ee945abab63a0b79 100644 |
--- a/content/common/gpu/client/gpu_channel_host.cc |
+++ b/content/common/gpu/client/gpu_channel_host.cc |
@@ -6,6 +6,7 @@ |
#include <algorithm> |
+#include "base/barrier_closure.h" |
#include "base/bind.h" |
#include "base/debug/trace_event.h" |
#include "base/message_loop/message_loop.h" |
@@ -50,7 +51,8 @@ GpuChannelHost::GpuChannelHost( |
cc::GpuMemoryBufferManager* gpu_memory_buffer_manager) |
: factory_(factory), |
gpu_info_(gpu_info), |
- gpu_memory_buffer_manager_(gpu_memory_buffer_manager) { |
+ gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
+ next_signal_id_(0) { |
next_transfer_buffer_id_.GetNext(); |
next_image_id_.GetNext(); |
next_route_id_.GetNext(); |
@@ -319,6 +321,48 @@ int32 GpuChannelHost::GenerateRouteID() { |
return next_route_id_.GetNext(); |
} |
+void GpuChannelHost::WaitForPendingGpuMemoryBufferUsageToComplete( |
+ const base::Closure& callback) { |
+ AutoLock lock(signal_lock_); |
+ uint32 signal_id = next_signal_id_++; |
+ signal_tasks_.insert(std::make_pair(signal_id, callback)); |
+ |
+ base::Closure proxy_barrier_closure = base::BarrierClosure( |
+ proxies_.size(), |
+ base::Bind(&GpuChannelHost::GpuMemoryBufferWaitCompleted, |
+ base::Unretained(this), |
reveman
2014/10/22 22:42:47
is this safe?
|
+ signal_id, |
+ base::MessageLoopProxy::current())); |
+ for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); it++) { |
+ it->second->WaitForPendingGpuMemoryBufferUsageToComplete( |
+ proxy_barrier_closure); |
+ } |
+} |
+ |
+void GpuChannelHost::GpuMemoryBufferWaitCompleted( |
reveman
2014/10/22 22:42:47
GpuMemoryBufferUsageCompleted
|
+ uint32 id, |
+ scoped_refptr<base::MessageLoopProxy> caller_message_loop) { |
+ caller_message_loop->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GpuChannelHost::GpuMemoryBufferWaitCompletedOnCallerThread, |
+ base::Unretained(this), |
reveman
2014/10/22 22:42:47
is this safe? what if the GpuChannelHost is delete
|
+ id)); |
+} |
+ |
+void GpuChannelHost::GpuMemoryBufferWaitCompletedOnCallerThread(uint32 id) { |
+ base::Closure callback; |
+ { |
+ AutoLock lock(signal_lock_); |
+ SignalTaskMap::iterator it = signal_tasks_.find(id); |
+ DCHECK(it != signal_tasks_.end()); |
+ |
+ callback = it->second; |
+ signal_tasks_.erase(it); |
+ } |
+ |
+ callback.Run(); |
+} |
+ |
GpuChannelHost::~GpuChannelHost() { |
// channel_ must be destroyed on the main thread. |
if (!factory_->IsMainThread()) |