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

Unified Diff: content/public/browser/web_contents_user_data.h

Issue 11085055: Make the WebContentsUserData locator key private. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, catch more uses of the key Created 8 years, 2 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 | « chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
};
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698