From 314c3e2d86a4595db7b1ab02b2acd4decf21d65f Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Tue, 21 Feb 2012 03:57:42 +0000 Subject: Remove getters for HTML5 related objects from the ResourceContext interface. Half of them weren't used by chrome, so they can be hidden from chrome. The rest were accessed by chrome, but we don't need every embedder to store this data on their ResourceContext implementation. Instead have content associate the data itself to simplify the work for embedders. BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9425026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122790 0039d316-1c4b-4281-b951-d872f2087c98 --- base/supports_user_data.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'base/supports_user_data.h') diff --git a/base/supports_user_data.h b/base/supports_user_data.h index 0296a3e..1c90e01 100644 --- a/base/supports_user_data.h +++ b/base/supports_user_data.h @@ -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 @@ class BASE_EXPORT SupportsUserData { DISALLOW_COPY_AND_ASSIGN(SupportsUserData); }; +// Adapter class that releases a refcounted object when the +// SupportsUserData::Data object is deleted. +template +class UserDataAdapter : public base::SupportsUserData::Data { + public: + static T* Get(SupportsUserData* supports_user_data, const char* key) { + UserDataAdapter* data = + static_cast(supports_user_data->GetUserData(key)); + return static_cast(data->object_.get()); + } + + UserDataAdapter(T* object) : object_(object) {} + + private: + scoped_refptr object_; + + DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); +}; + } // namespace base #endif // BASE_SUPPORTS_USER_DATA_H_ -- cgit v1.1