Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: components/exo/compositor_frame_sink_holder.cc

Issue 2584953002: exo::CompositorFrameSinkHolder's release callbacks hold ref (Closed)
Patch Set: Added comments explaining the fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/compositor_frame_sink_holder.cc
diff --git a/components/exo/compositor_frame_sink_holder.cc b/components/exo/compositor_frame_sink_holder.cc
index dd82aff4dc1dc915afc79434ccbb091dc0c6d476..aadd943861d80c8da24fb962e8926fa6bad94bda 100644
--- a/components/exo/compositor_frame_sink_holder.cc
+++ b/components/exo/compositor_frame_sink_holder.cc
@@ -83,10 +83,15 @@ void CompositorFrameSinkHolder::ReclaimResources(
for (auto& resource : resources) {
auto it = release_callbacks_.find(resource.id);
DCHECK(it != release_callbacks_.end());
- std::unique_ptr<cc::SingleReleaseCallback> callback =
- std::move(it->second.second);
+
+ // |callback_pair| is a std::pair<scoped_refptr<CompositorFrameSinkHolder>,
reveman 2016/12/19 18:20:02 So why doesn't simply: it->second.second->Run(res
Alex Z. 2016/12/19 18:34:03 The erase() triggers Release() of the scoped_refpt
reveman 2016/12/19 19:30:02 Ok, thanks for explaining. Instead of "auto callba
Alex Z. 2016/12/19 19:37:50 With that, the code would look really similar to w
Alex Z. 2016/12/19 20:05:39 In addition, it could still crash if more code is
reveman 2016/12/19 20:18:15 Yes, except the "holder(this)" part that is surpri
Alex Z. 2016/12/19 20:54:07 How do I post the task to the current message loop
+ // std::unique_ptr<cc::SingleReleaseCallback>>. The
+ // scoped_refptr<CompositorFrameSinkHolder> inside prevent
+ // CompositorFrameSinkHolder being destroyed before ReclaimResources()
+ // returns.
+ auto callback_pair = std::move(it->second);
release_callbacks_.erase(it);
- callback->Run(resource.sync_token, resource.lost);
+ callback_pair.second->Run(resource.sync_token, resource.lost);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698