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

Side by Side Diff: cc/base/ref_counted_managed.h

Issue 38553002: cc: Add tile pool to tile manager. (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 | « base/memory/ref_counted.cc ('k') | cc/resources/picture_layer_tiling_perftest.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_BASE_REF_COUNTED_MANAGED_H_ 5 #ifndef CC_BASE_REF_COUNTED_MANAGED_H_
6 #define CC_BASE_REF_COUNTED_MANAGED_H_ 6 #define CC_BASE_REF_COUNTED_MANAGED_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "cc/base/cc_export.h" 10 #include "cc/base/cc_export.h"
(...skipping 14 matching lines...) Expand all
25 25
26 private: 26 private:
27 friend class RefCountedManaged<T>; 27 friend class RefCountedManaged<T>;
28 int live_object_count_; 28 int live_object_count_;
29 }; 29 };
30 30
31 template <typename T> 31 template <typename T>
32 class CC_EXPORT RefCountedManaged : public base::subtle::RefCountedBase { 32 class CC_EXPORT RefCountedManaged : public base::subtle::RefCountedBase {
33 public: 33 public:
34 explicit RefCountedManaged(RefCountedManager<T>* manager) 34 explicit RefCountedManaged(RefCountedManager<T>* manager)
35 : manager_(manager) { 35 : manager_(manager),
36 manager_->live_object_count_++; 36 released_(true) {
37 } 37 }
38 38
39 void AddRef() const { 39 void AddRef() const {
40 if (released_) {
41 released_ = false;
42 ClearInDtor();
43 manager_->live_object_count_++;
44 }
40 base::subtle::RefCountedBase::AddRef(); 45 base::subtle::RefCountedBase::AddRef();
41 } 46 }
42 47
43 void Release() { 48 void Release() {
44 if (base::subtle::RefCountedBase::Release()) { 49 if (base::subtle::RefCountedBase::Release()) {
45 DCHECK_GT(manager_->live_object_count_, 0); 50 DCHECK_GT(manager_->live_object_count_, 0);
46 manager_->live_object_count_--; 51 manager_->live_object_count_--;
47 52
53 released_ = true;
54
48 // This must be the last statement in case manager deletes 55 // This must be the last statement in case manager deletes
49 // the object immediately. 56 // the object immediately.
50 manager_->Release(static_cast<T*>(this)); 57 manager_->Release(static_cast<T*>(this));
51 } 58 }
52 } 59 }
53 60
54 protected: 61 protected:
55 ~RefCountedManaged() {} 62 ~RefCountedManaged() {}
56 63
57 private: 64 private:
58 RefCountedManager<T>* manager_; 65 RefCountedManager<T>* manager_;
66 mutable bool released_;
59 67
60 DISALLOW_COPY_AND_ASSIGN(RefCountedManaged<T>); 68 DISALLOW_COPY_AND_ASSIGN(RefCountedManaged<T>);
61 }; 69 };
62 70
63 } // namespace cc 71 } // namespace cc
64 72
65 #endif // CC_BASE_REF_COUNTED_MANAGED_H_ 73 #endif // CC_BASE_REF_COUNTED_MANAGED_H_
OLDNEW
« no previous file with comments | « base/memory/ref_counted.cc ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698