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

Unified Diff: base/supports_user_data.h

Issue 9425026: Remove getters for HTML5 related objects from the ResourceContext interface. Half of them weren't u… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/supports_user_data.h
===================================================================
--- base/supports_user_data.h (revision 122771)
+++ base/supports_user_data.h (working copy)
@@ -9,6 +9,7 @@
#include "base/base_export.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/ref_counted.h"
namespace base {
@@ -42,6 +43,25 @@
DISALLOW_COPY_AND_ASSIGN(SupportsUserData);
};
+// Adapter class that releases a refcounted object when the
+// SupportsUserData::Data object is deleted.
+template <typename T>
+class UserDataAdapter : public base::SupportsUserData::Data {
+ public:
+ static T* Get(SupportsUserData* supports_user_data, const char* key) {
+ UserDataAdapter* data =
+ static_cast<UserDataAdapter*>(supports_user_data->GetUserData(key));
+ return static_cast<T*>(data->object_.get());
+ }
+
+ UserDataAdapter(T* object) : object_(object) {}
+
+ private:
+ scoped_refptr<T> object_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserDataAdapter);
+};
+
} // namespace base
#endif // BASE_SUPPORTS_USER_DATA_H_
« no previous file with comments | « no previous file | chrome/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698