Chromium Code Reviews| Index: ppapi/proxy/compositor_resource.cc |
| diff --git a/ppapi/proxy/compositor_resource.cc b/ppapi/proxy/compositor_resource.cc |
| index 3ada734849839aca56078ac7e3859b6d574df1a6..443d7a949e977bab3394e8e7c0fe181d02eed7ac 100644 |
| --- a/ppapi/proxy/compositor_resource.cc |
| +++ b/ppapi/proxy/compositor_resource.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/logging.h" |
| #include "ppapi/proxy/ppapi_messages.h" |
| +#include "ppapi/thunk/enter.h" |
| namespace ppapi { |
| namespace proxy { |
| @@ -18,8 +19,25 @@ CompositorResource::CompositorResource(Connection connection, |
| SendCreate(RENDERER, PpapiHostMsg_Compositor_Create()); |
| } |
| +bool CompositorResource::IsInProgress() const { |
| + ProxyLock::AssertAcquiredDebugOnly(); |
| + return TrackedCallback::IsPending(commit_callback_); |
| +} |
| + |
| +int32_t CompositorResource::GenerateResourceId() const { |
| + ProxyLock::AssertAcquiredDebugOnly(); |
| + return ++last_resource_id_; |
| +} |
| + |
| CompositorResource::~CompositorResource() { |
| - ResetLayersInternal(); |
| + ResetLayersInternal(true); |
| + |
| + // Abort all release callbacks. |
| + for (ReleaseCallbackMap::iterator it = release_callback_map_.begin(); |
| + it != release_callback_map_.end(); ++it) { |
| + if (!it->second.is_null()) |
| + it->second.Run(PP_ERROR_ABORTED, 0, false); |
| + } |
| } |
| thunk::PPB_Compositor_API* CompositorResource::AsPPB_Compositor_API() { |
| @@ -74,7 +92,8 @@ int32_t CompositorResource::CommitLayers( |
| int32_t CompositorResource::ResetLayers() { |
| if (IsInProgress()) |
| return PP_ERROR_INPROGRESS; |
| - ResetLayersInternal(); |
| + |
| + ResetLayersInternal(false); |
| return PP_OK; |
| } |
| @@ -112,16 +131,16 @@ void CompositorResource::OnPluginMsgReleaseResource( |
| ReleaseCallbackMap::iterator it = release_callback_map_.find(id); |
| DCHECK(it != release_callback_map_.end()) << |
| "Can not found release_callback_ by id(" << id << ")!"; |
| - it->second.Run(sync_point, is_lost); |
| + it->second.Run(PP_OK, sync_point, is_lost); |
| release_callback_map_.erase(it); |
| } |
| -void CompositorResource::ResetLayersInternal() { |
| +void CompositorResource::ResetLayersInternal(bool is_aborted) { |
| for (LayerList::iterator it = layers_.begin(); |
| it != layers_.end(); ++it) { |
| ReleaseCallback release_callback = (*it)->release_callback(); |
| if (!release_callback.is_null()) { |
| - release_callback.Run(0, false); |
| + release_callback.Run(is_aborted ? PP_ERROR_ABORTED : PP_OK, 0, false); |
|
piman
2014/06/19 23:18:32
Actually, why do we run the callback now when we c
piman
2014/06/20 01:24:56
Ok, this can only happen for layers that haven't b
|
| (*it)->ResetReleaseCallback(); |
| } |
| (*it)->Invalidate(); |