Chromium Code Reviews| 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); |
| } |
| } |