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

Unified Diff: chrome/browser/view_type_utils.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
Index: chrome/browser/view_type_utils.cc
diff --git a/chrome/browser/view_type_utils.cc b/chrome/browser/view_type_utils.cc
index 5118e0aacf03c9f1a061f853a1ba5644f64a640b..d24e9cf46323f276a93086e388401988497d62e4 100644
--- a/chrome/browser/view_type_utils.cc
+++ b/chrome/browser/view_type_utils.cc
@@ -5,31 +5,41 @@
#include "chrome/browser/view_type_utils.h"
#include "base/lazy_instance.h"
-#include "base/property_bag.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
namespace chrome {
-static base::LazyInstance<base::PropertyAccessor<ViewType> >
- g_view_type_property_accessor = LAZY_INSTANCE_INITIALIZER;
+namespace {
-base::PropertyAccessor<ViewType>* GetPropertyAccessor() {
- return g_view_type_property_accessor.Pointer();
-}
+const char kViewTypeUserDataKey[] = "ViewTypeUserData";
+
+class ViewTypeUserData : public base::SupportsUserData::Data {
+ public:
+ explicit ViewTypeUserData(ViewType type) : type_(type) {}
+ virtual ~ViewTypeUserData() {}
+ ViewType type() { return type_; }
+
+ private:
+ ViewType type_;
+};
+
+} // namespace
ViewType GetViewType(WebContents* tab) {
if (!tab)
return VIEW_TYPE_INVALID;
- ViewType* type = GetPropertyAccessor()->GetProperty(tab->GetPropertyBag());
- if (type)
- return *type;
- return VIEW_TYPE_INVALID;
+
+ ViewTypeUserData* user_data = static_cast<ViewTypeUserData*>(
+ tab->GetUserData(&kViewTypeUserDataKey));
+
+ return user_data ? user_data->type() : VIEW_TYPE_INVALID;
}
void SetViewType(WebContents* tab, ViewType type) {
- GetPropertyAccessor()->SetProperty(tab->GetPropertyBag(), type);
+ tab->SetUserData(&kViewTypeUserDataKey,
+ new ViewTypeUserData(type));
}
} // namespace chrome
« no previous file with comments | « chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698