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

Unified Diff: cc/layers/delegated_frame_resource_collection.cc

Issue 47703005: Fix DelegatedFrameResourceCollection thread safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months 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
Index: cc/layers/delegated_frame_resource_collection.cc
diff --git a/cc/layers/delegated_frame_resource_collection.cc b/cc/layers/delegated_frame_resource_collection.cc
index cd2633dc2aec56437013b2d42dcc13374083a4ae..5ca4eda57d761bed7998ae75964a136c979ddae9 100644
--- a/cc/layers/delegated_frame_resource_collection.cc
+++ b/cc/layers/delegated_frame_resource_collection.cc
@@ -12,7 +12,8 @@ namespace cc {
DelegatedFrameResourceCollection::DelegatedFrameResourceCollection()
: client_(NULL),
main_thread_runner_(BlockingTaskRunner::current()),
- lost_all_resources_(false) {
+ lost_all_resources_(false),
+ weak_ptr_factory_(this) {
DCHECK(main_thread_checker_.CalledOnValidThread());
}
@@ -112,21 +113,21 @@ void DelegatedFrameResourceCollection::RefResources(
resource_id_ref_count_map_[resources[i].id].refs_to_wait_for++;
}
-ReturnCallback
-DelegatedFrameResourceCollection::GetReturnResourcesCallbackForImplThread() {
- return base::Bind(
- &DelegatedFrameResourceCollection::UnrefResourcesOnImplThread,
- this,
- main_thread_runner_);
-}
-
-void DelegatedFrameResourceCollection::UnrefResourcesOnImplThread(
+static void UnrefResourcesOnImplThread(
+ base::WeakPtr<DelegatedFrameResourceCollection> self,
scoped_refptr<BlockingTaskRunner> main_thread_runner,
const ReturnedResourceArray& returned) {
main_thread_runner->PostTask(
FROM_HERE,
base::Bind(
- &DelegatedFrameResourceCollection::UnrefResources, this, returned));
+ &DelegatedFrameResourceCollection::UnrefResources, self, returned));
+}
+
+ReturnCallback
+DelegatedFrameResourceCollection::GetReturnResourcesCallbackForImplThread() {
+ return base::Bind(&UnrefResourcesOnImplThread,
+ weak_ptr_factory_.GetWeakPtr(),
+ main_thread_runner_);
}
} // namespace cc
« no previous file with comments | « cc/layers/delegated_frame_resource_collection.h ('k') | cc/layers/delegated_frame_resource_collection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698