| Index: content/public/browser/web_contents_user_data.h
|
| diff --git a/content/public/browser/web_contents_user_data.h b/content/public/browser/web_contents_user_data.h
|
| index 9dfe170cddd81d586d11774b6af1d7458d1c87d5..a65ec84cf9c2bc3c8e6b813ef06103822a240d76 100644
|
| --- a/content/public/browser/web_contents_user_data.h
|
| +++ b/content/public/browser/web_contents_user_data.h
|
| @@ -35,7 +35,7 @@ class WebContentsUserData : public base::SupportsUserData::Data {
|
| static void CreateForWebContents(WebContents* contents) {
|
| DCHECK(contents);
|
| if (!FromWebContents(contents))
|
| - contents->SetUserData(&kLocatorKey, new T(contents));
|
| + contents->SetUserData(UserDataKey(), new T(contents));
|
| }
|
|
|
| // Retrieves the instance of type T that was attached to the specified
|
| @@ -43,13 +43,19 @@ class WebContentsUserData : public base::SupportsUserData::Data {
|
| // of the type was attached, returns NULL.
|
| static T* FromWebContents(WebContents* contents) {
|
| DCHECK(contents);
|
| - return static_cast<T*>(contents->GetUserData(&kLocatorKey));
|
| + return static_cast<T*>(contents->GetUserData(UserDataKey()));
|
| }
|
| static const T* FromWebContents(const WebContents* contents) {
|
| DCHECK(contents);
|
| - return static_cast<const T*>(contents->GetUserData(&kLocatorKey));
|
| + return static_cast<const T*>(contents->GetUserData(UserDataKey()));
|
| }
|
|
|
| + protected:
|
| + static inline void* UserDataKey() {
|
| + return &kLocatorKey;
|
| + }
|
| +
|
| + private:
|
| // The user data key.
|
| static int kLocatorKey;
|
| };
|
|
|