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

Side by Side Diff: base/supports_user_data.h

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « base/strings/sys_string_conversions_posix.cc ('k') | build/all.gyp » ('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 (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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ThreadChecker thread_checker_; 54 ThreadChecker thread_checker_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(SupportsUserData); 56 DISALLOW_COPY_AND_ASSIGN(SupportsUserData);
57 }; 57 };
58 58
59 // Adapter class that releases a refcounted object when the 59 // Adapter class that releases a refcounted object when the
60 // SupportsUserData::Data object is deleted. 60 // SupportsUserData::Data object is deleted.
61 template <typename T> 61 template <typename T>
62 class UserDataAdapter : public base::SupportsUserData::Data { 62 class UserDataAdapter : public base::SupportsUserData::Data {
63 public: 63 public:
64 static T* Get(SupportsUserData* supports_user_data, const void* key) { 64 static T* Get(const SupportsUserData* supports_user_data, const void* key) {
65 UserDataAdapter* data = 65 UserDataAdapter* data =
66 static_cast<UserDataAdapter*>(supports_user_data->GetUserData(key)); 66 static_cast<UserDataAdapter*>(supports_user_data->GetUserData(key));
67 return data ? static_cast<T*>(data->object_.get()) : NULL; 67 return data ? static_cast<T*>(data->object_.get()) : NULL;
68 } 68 }
69 69
70 UserDataAdapter(T* object) : object_(object) {} 70 UserDataAdapter(T* object) : object_(object) {}
71 T* release() { return object_.release(); } 71 T* release() { return object_.release(); }
72 72
73 private: 73 private:
74 scoped_refptr<T> object_; 74 scoped_refptr<T> object_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); 76 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter);
77 }; 77 };
78 78
79 } // namespace base 79 } // namespace base
80 80
81 #endif // BASE_SUPPORTS_USER_DATA_H_ 81 #endif // BASE_SUPPORTS_USER_DATA_H_
OLDNEW
« no previous file with comments | « base/strings/sys_string_conversions_posix.cc ('k') | build/all.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698