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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 template <typename T> | 48 template <typename T> |
49 class UserDataAdapter : public base::SupportsUserData::Data { | 49 class UserDataAdapter : public base::SupportsUserData::Data { |
50 public: | 50 public: |
51 static T* Get(SupportsUserData* supports_user_data, const char* key) { | 51 static T* Get(SupportsUserData* supports_user_data, const char* key) { |
52 UserDataAdapter* data = | 52 UserDataAdapter* data = |
53 static_cast<UserDataAdapter*>(supports_user_data->GetUserData(key)); | 53 static_cast<UserDataAdapter*>(supports_user_data->GetUserData(key)); |
54 return static_cast<T*>(data->object_.get()); | 54 return static_cast<T*>(data->object_.get()); |
55 } | 55 } |
56 | 56 |
57 UserDataAdapter(T* object) : object_(object) {} | 57 UserDataAdapter(T* object) : object_(object) {} |
| 58 T* release() { return object_.release(); } |
58 | 59 |
59 private: | 60 private: |
60 scoped_refptr<T> object_; | 61 scoped_refptr<T> object_; |
61 | 62 |
62 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); | 63 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); |
63 }; | 64 }; |
64 | 65 |
65 } // namespace base | 66 } // namespace base |
66 | 67 |
67 #endif // BASE_SUPPORTS_USER_DATA_H_ | 68 #endif // BASE_SUPPORTS_USER_DATA_H_ |
OLD | NEW |