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

Unified Diff: chrome/browser/ui/tab_contents/tab_contents.cc

Issue 10831407: Kill PropertyBag, switch WebContents to SupportsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 4 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/tab_contents/tab_contents.h ('k') | chrome/browser/ui/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tab_contents/tab_contents.cc
diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc
index d1fdb6b5f1724039b0d8ca1dc28552c5de3447a6..b905d5f7d379091303603c63feb69cf23e55eb90 100644
--- a/chrome/browser/ui/tab_contents/tab_contents.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents.cc
@@ -64,8 +64,18 @@ using content::WebContents;
namespace {
-static base::LazyInstance<base::PropertyAccessor<TabContents*> >
- g_tab_contents_property_accessor = LAZY_INSTANCE_INITIALIZER;
+const char kTabContentsUserDataKey[] = "TabContentsUserData";
+
+class TabContentsUserData : public base::SupportsUserData::Data {
+ public:
+ explicit TabContentsUserData(TabContents* tab_contents)
+ : tab_contents_(tab_contents) {}
+ virtual ~TabContentsUserData() {}
+ TabContents* tab_contents() { return tab_contents_; }
+
+ private:
+ TabContents* tab_contents_; // unowned
+};
} // namespace
@@ -81,9 +91,9 @@ TabContents::TabContents(WebContents* contents)
chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS);
- // Stash this in the property bag so it can be retrieved without having to
- // go to a Browser.
- property_accessor()->SetProperty(contents->GetPropertyBag(), this);
+ // Stash this in the WebContents.
+ contents->SetUserData(&kTabContentsUserDataKey,
+ new TabContentsUserData(this));
// Create the tab helpers.
// restore_tab_helper because it sets up the tab ID, and other helpers may
@@ -205,10 +215,6 @@ TabContents::~TabContents() {
infobar_tab_helper_.reset();
}
-base::PropertyAccessor<TabContents*>* TabContents::property_accessor() {
- return g_tab_contents_property_accessor.Pointer();
-}
-
TabContents* TabContents::Clone() {
WebContents* new_web_contents = web_contents()->Clone();
TabContents* new_tab_contents = new TabContents(new_web_contents);
@@ -222,18 +228,18 @@ TabContents* TabContents::Clone() {
// static
TabContents* TabContents::FromWebContents(WebContents* contents) {
- TabContents** tab_contents =
- property_accessor()->GetProperty(contents->GetPropertyBag());
+ TabContentsUserData* user_data = static_cast<TabContentsUserData*>(
+ contents->GetUserData(&kTabContentsUserDataKey));
- return tab_contents ? *tab_contents : NULL;
+ return user_data ? user_data->tab_contents() : NULL;
}
// static
const TabContents* TabContents::FromWebContents(const WebContents* contents) {
- TabContents* const* tab_contents =
- property_accessor()->GetProperty(contents->GetPropertyBag());
+ TabContentsUserData* user_data = static_cast<TabContentsUserData*>(
+ contents->GetUserData(&kTabContentsUserDataKey));
- return tab_contents ? *tab_contents : NULL;
+ return user_data ? user_data->tab_contents() : NULL;
}
WebContents* TabContents::web_contents() const {
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents.h ('k') | chrome/browser/ui/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698