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

Side by Side Diff: cc/layers/delegated_frame_resource_collection.h

Issue 47703005: Fix DelegatedFrameResourceCollection thread safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/layers/delegated_frame_resource_collection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ 5 #ifndef CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_
6 #define CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ 6 #define CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_
7 7
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
11 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
12 #include "cc/resources/return_callback.h" 13 #include "cc/resources/return_callback.h"
13 #include "cc/resources/returned_resource.h" 14 #include "cc/resources/returned_resource.h"
14 #include "cc/resources/transferable_resource.h" 15 #include "cc/resources/transferable_resource.h"
15 16
16 namespace cc { 17 namespace cc {
17 class BlockingTaskRunner; 18 class BlockingTaskRunner;
18 19
19 class CC_EXPORT DelegatedFrameResourceCollectionClient { 20 class CC_EXPORT DelegatedFrameResourceCollectionClient {
(...skipping 19 matching lines...) Expand all
39 // Methods for DelegatedFrameProvider. 40 // Methods for DelegatedFrameProvider.
40 void RefResources(const TransferableResourceArray& resources); 41 void RefResources(const TransferableResourceArray& resources);
41 void UnrefResources(const ReturnedResourceArray& returned); 42 void UnrefResources(const ReturnedResourceArray& returned);
42 void ReceivedResources(const TransferableResourceArray& resources); 43 void ReceivedResources(const TransferableResourceArray& resources);
43 ReturnCallback GetReturnResourcesCallbackForImplThread(); 44 ReturnCallback GetReturnResourcesCallbackForImplThread();
44 45
45 private: 46 private:
46 friend class base::RefCounted<DelegatedFrameResourceCollection>; 47 friend class base::RefCounted<DelegatedFrameResourceCollection>;
47 ~DelegatedFrameResourceCollection(); 48 ~DelegatedFrameResourceCollection();
48 49
49 void UnrefResourcesOnImplThread(
50 scoped_refptr<BlockingTaskRunner> main_thread_runner,
51 const ReturnedResourceArray& returned);
52
53 DelegatedFrameResourceCollectionClient* client_; 50 DelegatedFrameResourceCollectionClient* client_;
54 scoped_refptr<BlockingTaskRunner> main_thread_runner_; 51 scoped_refptr<BlockingTaskRunner> main_thread_runner_;
55 52
56 ReturnedResourceArray returned_resources_for_child_compositor_; 53 ReturnedResourceArray returned_resources_for_child_compositor_;
57 bool lost_all_resources_; 54 bool lost_all_resources_;
58 55
59 struct RefCount { 56 struct RefCount {
60 int refs_to_return; 57 int refs_to_return;
61 int refs_to_wait_for; 58 int refs_to_wait_for;
62 }; 59 };
63 typedef base::hash_map<unsigned, RefCount> ResourceIdRefCountMap; 60 typedef base::hash_map<unsigned, RefCount> ResourceIdRefCountMap;
64 ResourceIdRefCountMap resource_id_ref_count_map_; 61 ResourceIdRefCountMap resource_id_ref_count_map_;
65 62
66 base::ThreadChecker main_thread_checker_; 63 base::ThreadChecker main_thread_checker_;
64 base::WeakPtrFactory<DelegatedFrameResourceCollection> weak_ptr_factory_;
67 65
68 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameResourceCollection); 66 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameResourceCollection);
69 }; 67 };
70 68
71 } // namespace cc 69 } // namespace cc
72 70
73 #endif // CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ 71 #endif // CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/layers/delegated_frame_resource_collection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698