OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 BASE_REVOCABLE_STORE_H__ | 5 #ifndef BASE_REVOCABLE_STORE_H__ |
6 #define BASE_REVOCABLE_STORE_H__ | 6 #define BASE_REVOCABLE_STORE_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 | 11 |
12 // |RevocableStore| is a container of items that can be removed from the store. | 12 // |RevocableStore| is a container of items that can be removed from the store. |
13 class RevocableStore { | 13 class RevocableStore { |
14 public: | 14 public: |
15 // A |StoreRef| is used to link the |RevocableStore| to its items. There is | 15 // A |StoreRef| is used to link the |RevocableStore| to its items. There is |
16 // one StoreRef per store, and each item holds a reference to it. If the | 16 // one StoreRef per store, and each item holds a reference to it. If the |
17 // store wishes to revoke its items, it sets |store_| to null. Items are | 17 // store wishes to revoke its items, it sets |store_| to null. Items are |
18 // permitted to release their reference to the |StoreRef| when they no longer | 18 // permitted to release their reference to the |StoreRef| when they no longer |
19 // require the store. | 19 // require the store. |
20 class StoreRef : public base::RefCounted<StoreRef> { | 20 class StoreRef : public base::RefCountedThreadSafe<StoreRef> { |
21 public: | 21 public: |
22 StoreRef(RevocableStore* store) : store_(store) { } | 22 StoreRef(RevocableStore* store) : store_(store) { } |
23 | 23 |
24 void set_store(RevocableStore* store) { store_ = store; } | 24 void set_store(RevocableStore* store) { store_ = store; } |
25 RevocableStore* store() const { return store_; } | 25 RevocableStore* store() const { return store_; } |
26 | 26 |
27 private: | 27 private: |
28 RevocableStore* store_; | 28 RevocableStore* store_; |
29 | 29 |
30 DISALLOW_EVIL_CONSTRUCTORS(StoreRef); | 30 DISALLOW_EVIL_CONSTRUCTORS(StoreRef); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 scoped_refptr<StoreRef> owning_reference_; | 68 scoped_refptr<StoreRef> owning_reference_; |
69 | 69 |
70 // The number of unrevoked items in the store. | 70 // The number of unrevoked items in the store. |
71 int count_; | 71 int count_; |
72 | 72 |
73 DISALLOW_EVIL_CONSTRUCTORS(RevocableStore); | 73 DISALLOW_EVIL_CONSTRUCTORS(RevocableStore); |
74 }; | 74 }; |
75 | 75 |
76 #endif // BASE_REVOCABLE_STORE_H__ | 76 #endif // BASE_REVOCABLE_STORE_H__ |
77 | 77 |
OLD | NEW |