OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SUPPORTS_USER_DATA_H_ | 5 #ifndef BASE_SUPPORTS_USER_DATA_H_ |
6 #define BASE_SUPPORTS_USER_DATA_H_ | 6 #define BASE_SUPPORTS_USER_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 virtual ~Data() {} | 26 virtual ~Data() {} |
27 }; | 27 }; |
28 | 28 |
29 // The user data allows the clients to associate data with this object. | 29 // The user data allows the clients to associate data with this object. |
30 // Multiple user data values can be stored under different keys. | 30 // Multiple user data values can be stored under different keys. |
31 // This object will TAKE OWNERSHIP of the given data pointer, and will | 31 // This object will TAKE OWNERSHIP of the given data pointer, and will |
32 // delete the object if it is changed or the object is destroyed. | 32 // delete the object if it is changed or the object is destroyed. |
33 Data* GetUserData(const void* key) const; | 33 Data* GetUserData(const void* key) const; |
34 void SetUserData(const void* key, Data* data); | 34 void SetUserData(const void* key, Data* data); |
| 35 void RemoveUserData(const void* key); |
35 | 36 |
36 protected: | 37 protected: |
37 virtual ~SupportsUserData(); | 38 virtual ~SupportsUserData(); |
38 | 39 |
39 private: | 40 private: |
40 typedef std::map<const void*, linked_ptr<Data> > DataMap; | 41 typedef std::map<const void*, linked_ptr<Data> > DataMap; |
41 | 42 |
42 // Externally-defined data accessible by key | 43 // Externally-defined data accessible by key |
43 DataMap user_data_; | 44 DataMap user_data_; |
44 | 45 |
(...skipping 16 matching lines...) Expand all Loading... |
61 | 62 |
62 private: | 63 private: |
63 scoped_refptr<T> object_; | 64 scoped_refptr<T> object_; |
64 | 65 |
65 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); | 66 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); |
66 }; | 67 }; |
67 | 68 |
68 } // namespace base | 69 } // namespace base |
69 | 70 |
70 #endif // BASE_SUPPORTS_USER_DATA_H_ | 71 #endif // BASE_SUPPORTS_USER_DATA_H_ |
OLD | NEW |