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

Unified Diff: cc/surfaces/surface_factory.cc

Issue 2480203002: ui: Cleanup class/struct forward declarations (Closed)
Patch Set: Sync CL to position 430550 Created 4 years, 1 month 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 | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_factory.cc
diff --git a/cc/surfaces/surface_factory.cc b/cc/surfaces/surface_factory.cc
index 19fd8910d660480a0c2e235b452d9330ab6ddfd9..36a79ee9e9ad0557aa92978a661bb961dd56ed6b 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,17 @@ void SurfaceFactory::DestroyAll() {
surface_map_.clear();
}
+void SurfaceFactory::Reset() {
+ DestroyAll();
+ // Disown Surfaces that are still alive so that they don't try to unref
+ // resources that we're not tracking any more.
+ weak_factory_.InvalidateWeakPtrs();
+ 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);
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698