Chromium Code Reviews| Index: cc/surfaces/surface_factory.cc |
| diff --git a/cc/surfaces/surface_factory.cc b/cc/surfaces/surface_factory.cc |
| index 19fd8910d660480a0c2e235b452d9330ab6ddfd9..7d71f0632d00919e88a6d8cdb72a19eac77221cd 100644 |
| --- a/cc/surfaces/surface_factory.cc |
| +++ b/cc/surfaces/surface_factory.cc |
| @@ -22,7 +22,8 @@ SurfaceFactory::SurfaceFactory(const FrameSinkId& frame_sink_id, |
| manager_(manager), |
| client_(client), |
| holder_(client), |
| - needs_sync_points_(true) {} |
| + needs_sync_points_(true), |
| + weak_factory_(this) {} |
| SurfaceFactory::~SurfaceFactory() { |
| if (!surface_map_.empty()) { |
| @@ -40,9 +41,15 @@ void SurfaceFactory::DestroyAll() { |
| surface_map_.clear(); |
| } |
| +void SurfaceFactory::Reset() { |
| + DestroyAll(); |
| + weak_factory_.InvalidateWeakPtrs(); |
|
Fady Samuel
2016/11/05 05:26:44
nit: might be useful to comment about how Surfaces
piman
2016/11/07 18:55:41
Done.
|
| + holder_.Reset(); |
| +} |
| + |
| void SurfaceFactory::Create(const LocalFrameId& local_frame_id) { |
| - std::unique_ptr<Surface> surface(base::MakeUnique<Surface>( |
| - SurfaceId(frame_sink_id_, local_frame_id), this)); |
| + auto surface(base::MakeUnique<Surface>( |
| + SurfaceId(frame_sink_id_, local_frame_id), weak_factory_.GetWeakPtr())); |
| manager_->RegisterSurface(surface.get()); |
| DCHECK(!surface_map_.count(local_frame_id)); |
| surface_map_[local_frame_id] = std::move(surface); |