diff options
23 files changed, 77 insertions, 53 deletions
diff --git a/base/base.gyp b/base/base.gyp index a45ac6d..cb0fb05 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -185,6 +185,7 @@ 'process_util_unittest_mac.h', 'process_util_unittest_mac.mm', 'profiler/tracked_time_unittest.cc', + 'property_bag_unittest.cc', 'rand_util_unittest.cc', 'scoped_native_library_unittest.cc', 'scoped_temp_dir_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index 7d1a1c7..8402a88 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -229,6 +229,8 @@ 'profiler/scoped_profile.h', 'profiler/tracked_time.cc', 'profiler/tracked_time.h', + 'property_bag.cc', + 'property_bag.h', 'rand_util.cc', 'rand_util.h', 'rand_util_c.h', diff --git a/content/common/property_bag.cc b/base/property_bag.cc index ec3cc5c..9578e64 100644 --- a/content/common/property_bag.cc +++ b/base/property_bag.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/property_bag.h" + #include "base/memory/linked_ptr.h" -#include "content/common/property_bag.h" + +namespace base { PropertyBag::PropertyBag() { } @@ -54,3 +57,5 @@ PropertyAccessorBase::PropertyAccessorBase() { static PropertyBag::PropID next_id = 1; prop_id_ = next_id++; } + +} // namespace base diff --git a/content/common/property_bag.h b/base/property_bag.h index b83cc58..42fa1b9 100644 --- a/content/common/property_bag.h +++ b/base/property_bag.h @@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMMON_PROPERTY_BAG_H_ -#define CONTENT_COMMON_PROPERTY_BAG_H_ +#ifndef BASE_PROPERTY_BAG_H_ +#define BASE_PROPERTY_BAG_H_ #pragma once #include <map> #include "base/basictypes.h" -#include "content/common/content_export.h" +#include "base/base_export.h" + +template <typename T> class linked_ptr; + +namespace base { -template <typename T> -class linked_ptr; class PropertyAccessorBase; // A property bag holds a generalized list of arbitrary metadata called @@ -43,7 +45,7 @@ class PropertyAccessorBase; // // accessor->SetProperty(object, 22); // } -class CONTENT_EXPORT PropertyBag { +class BASE_EXPORT PropertyBag { public: // The type that uniquely identifies a property type. typedef int PropID; @@ -94,7 +96,7 @@ class CONTENT_EXPORT PropertyBag { // Manages getting the unique IDs to identify a property. Callers should use // PropertyAccessor below instead. -class CONTENT_EXPORT PropertyAccessorBase { +class BASE_EXPORT PropertyAccessorBase { public: PropertyAccessorBase(); virtual ~PropertyAccessorBase() {} @@ -173,4 +175,6 @@ class PropertyAccessor : public PropertyAccessorBase { DISALLOW_COPY_AND_ASSIGN(PropertyAccessor); }; -#endif // CONTENT_COMMON_PROPERTY_BAG_H_ +} // namespace base + +#endif // BASE_PROPERTY_BAG_H_ diff --git a/content/common/property_bag_unittest.cc b/base/property_bag_unittest.cc index ed84099..b267d04 100644 --- a/content/common/property_bag_unittest.cc +++ b/base/property_bag_unittest.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/property_bag.h" +#include "base/property_bag.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { + TEST(PropertyBagTest, AddQueryRemove) { PropertyBag bag; PropertyAccessor<int> adaptor; @@ -60,3 +62,5 @@ TEST(PropertyBagTest, Copy) { EXPECT_TRUE(adaptor1.GetProperty(©) == NULL); EXPECT_TRUE(adaptor2.GetProperty(©) == NULL); } + +} // namespace base diff --git a/chrome/browser/extensions/extension_omnibox_api.cc b/chrome/browser/extensions/extension_omnibox_api.cc index 300333e..20a1a8d 100644 --- a/chrome/browser/extensions/extension_omnibox_api.cc +++ b/chrome/browser/extensions/extension_omnibox_api.cc @@ -40,11 +40,11 @@ const char kDescriptionStylesType[] = "type"; const char kDescriptionStylesOffset[] = "offset"; const char kDescriptionStylesLength[] = "length"; -static base::LazyInstance<PropertyAccessor<ExtensionOmniboxSuggestion> > +static base::LazyInstance<base::PropertyAccessor<ExtensionOmniboxSuggestion> > g_extension_omnibox_suggestion_property_accessor = LAZY_INSTANCE_INITIALIZER; -PropertyAccessor<ExtensionOmniboxSuggestion>& GetPropertyAccessor() { +base::PropertyAccessor<ExtensionOmniboxSuggestion>& GetPropertyAccessor() { return g_extension_omnibox_suggestion_property_accessor.Get(); } diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index d51c3f6..009dedb 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -2438,7 +2438,8 @@ void ExtensionService::SetHasUsedWebRequest(const Extension* extension, extension_runtime_data_[extension->id()].has_used_webrequest = value; } -PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { +base::PropertyBag* ExtensionService::GetPropertyBag( + const Extension* extension) { return &extension_runtime_data_[extension->id()].property_bag; } diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h index 4c1c58e..677fb19 100644 --- a/chrome/browser/extensions/extension_service.h +++ b/chrome/browser/extensions/extension_service.h @@ -19,6 +19,7 @@ #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/property_bag.h" #include "base/time.h" #include "base/tuple.h" #include "chrome/browser/extensions/apps_promo.h" @@ -40,7 +41,6 @@ #include "chrome/browser/sync/api/syncable_service.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" -#include "content/common/property_bag.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -243,7 +243,7 @@ class ExtensionService void SetHasUsedWebRequest(const Extension* extension, bool value); // Getter for the extension's runtime data PropertyBag. - PropertyBag* GetPropertyBag(const Extension* extension); + base::PropertyBag* GetPropertyBag(const Extension* extension); // Initialize and start all installed extensions. void Init(); @@ -575,7 +575,7 @@ class ExtensionService bool has_used_webrequest; // Generic bag of runtime data that users can associate with extensions. - PropertyBag property_bag; + base::PropertyBag property_bag; ExtensionRuntimeData(); ~ExtensionRuntimeData(); diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 9267058..1e50b32 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -11,6 +11,7 @@ #include "base/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" +#include "base/property_bag.h" #include "base/stl_util.h" #include "base/string_number_conversions.h" #include "base/string_split.h" @@ -31,7 +32,6 @@ #include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/common/property_bag.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" @@ -256,8 +256,8 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { } private: - PropertyAccessor<int>* GetIDAccessor() { - static PropertyAccessor<int> accessor; + base::PropertyAccessor<int>* GetIDAccessor() { + static base::PropertyAccessor<int> accessor; return &accessor; } diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm index 230fedd..38aa4b3 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm @@ -103,8 +103,9 @@ struct OmniboxViewMacState { // state in a TabContents. When constructed |accessor| generates a // globally-unique id used to index into the per-tab PropertyBag used // to store the state data. -PropertyAccessor<OmniboxViewMacState>* GetStateAccessor() { - CR_DEFINE_STATIC_LOCAL(PropertyAccessor<OmniboxViewMacState>, accessor, ()); +base::PropertyAccessor<OmniboxViewMacState>* GetStateAccessor() { + CR_DEFINE_STATIC_LOCAL( + base::PropertyAccessor<OmniboxViewMacState>, accessor, ()); return &accessor; } diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc index 6d03644..a33f839 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc @@ -105,8 +105,9 @@ struct AutocompleteEditState { // Returns a lazily initialized property bag accessor for saving our state in a // TabContents. -PropertyAccessor<AutocompleteEditState>* GetStateAccessor() { - CR_DEFINE_STATIC_LOCAL(PropertyAccessor<AutocompleteEditState>, state, ()); +base::PropertyAccessor<AutocompleteEditState>* GetStateAccessor() { + CR_DEFINE_STATIC_LOCAL( + base::PropertyAccessor<AutocompleteEditState>, state, ()); return &state; } diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index a8b57fe..0413250 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -65,7 +65,7 @@ namespace { -static base::LazyInstance<PropertyAccessor<TabContentsWrapper*> > +static base::LazyInstance<base::PropertyAccessor<TabContentsWrapper*> > g_tab_contents_wrapper_property_accessor = LAZY_INSTANCE_INITIALIZER; // The list of prefs we want to observe. @@ -362,7 +362,8 @@ TabContentsWrapper::~TabContentsWrapper() { infobar_tab_helper_.reset(); } -PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() { +base::PropertyAccessor<TabContentsWrapper*>* + TabContentsWrapper::property_accessor() { return g_tab_contents_wrapper_property_accessor.Pointer(); } diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 91b8a57..0844291 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -90,7 +90,7 @@ class TabContentsWrapper : public TabContentsObserver, // Used to retrieve this object from |tab_contents_|, which is placed in // its property bag to avoid adding additional interfaces. - static PropertyAccessor<TabContentsWrapper*>* property_accessor(); + static base::PropertyAccessor<TabContentsWrapper*>* property_accessor(); static void RegisterUserPrefs(PrefService* prefs); diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 8defd93..0b958c0 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -108,8 +108,9 @@ struct AutocompleteEditState { // Returns a lazily initialized property bag accessor for saving our state in a // TabContents. -PropertyAccessor<AutocompleteEditState>* GetStateAccessor() { - CR_DEFINE_STATIC_LOCAL(PropertyAccessor<AutocompleteEditState>, state, ()); +base::PropertyAccessor<AutocompleteEditState>* GetStateAccessor() { + CR_DEFINE_STATIC_LOCAL( + base::PropertyAccessor<AutocompleteEditState>, state, ()); return &state; } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc index 9c1723d..cce7d39 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc @@ -366,8 +366,8 @@ BOOL WINAPI EndPaintIntercept(HWND hWnd, const PAINTSTRUCT* lpPaint) { // Returns a lazily initialized property bag accessor for saving our state in a // TabContents. -PropertyAccessor<AutocompleteEditState>* GetStateAccessor() { - static PropertyAccessor<AutocompleteEditState> state; +base::PropertyAccessor<AutocompleteEditState>* GetStateAccessor() { + static base::PropertyAccessor<AutocompleteEditState> state; return &state; } diff --git a/chrome/browser/ui/webui/constrained_html_ui.cc b/chrome/browser/ui/webui/constrained_html_ui.cc index c0a5b84..6549242 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.cc +++ b/chrome/browser/ui/webui/constrained_html_ui.cc @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/lazy_instance.h" +#include "base/property_bag.h" #include "base/values.h" #include "chrome/browser/ui/webui/html_dialog_ui.h" #include "chrome/common/chrome_notification_types.h" @@ -17,7 +18,7 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" -static base::LazyInstance<PropertyAccessor<ConstrainedHtmlUIDelegate*> > +static base::LazyInstance<base::PropertyAccessor<ConstrainedHtmlUIDelegate*> > g_constrained_html_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; ConstrainedHtmlUI::ConstrainedHtmlUI(TabContents* contents) @@ -73,7 +74,7 @@ ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { } // static -PropertyAccessor<ConstrainedHtmlUIDelegate*>& +base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& ConstrainedHtmlUI::GetPropertyAccessor() { return g_constrained_html_ui_property_accessor.Get(); } diff --git a/chrome/browser/ui/webui/constrained_html_ui.h b/chrome/browser/ui/webui/constrained_html_ui.h index 03d2022..77c2b3b 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.h +++ b/chrome/browser/ui/webui/constrained_html_ui.h @@ -7,7 +7,6 @@ #pragma once #include "chrome/browser/ui/webui/chrome_web_ui.h" -#include "content/common/property_bag.h" class ConstrainedWindow; class HtmlDialogUIDelegate; @@ -16,6 +15,10 @@ class RenderViewHost; class TabContents; class TabContentsWrapper; +namespace base { +template<class T> class PropertyAccessor; +} + class ConstrainedHtmlUIDelegate { public: virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; @@ -62,7 +65,7 @@ class ConstrainedHtmlUI : public ChromeWebUI { // Returns a property accessor that can be used to set the // ConstrainedHtmlUIDelegate property on a TabContents. - static PropertyAccessor<ConstrainedHtmlUIDelegate*>& + static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& GetPropertyAccessor(); protected: diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/html_dialog_ui.cc index 4d5b678..788ee23 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.cc +++ b/chrome/browser/ui/webui/html_dialog_ui.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/lazy_instance.h" +#include "base/property_bag.h" #include "base/values.h" #include "chrome/common/chrome_notification_types.h" #include "content/browser/renderer_host/render_view_host.h" @@ -14,7 +15,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/common/bindings_policy.h" -static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> > +static base::LazyInstance<base::PropertyAccessor<HtmlDialogUIDelegate*> > g_html_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; HtmlDialogUI::HtmlDialogUI(TabContents* tab_contents) @@ -37,7 +38,8 @@ void HtmlDialogUI::CloseDialog(const base::ListValue* args) { } // static -PropertyAccessor<HtmlDialogUIDelegate*>& HtmlDialogUI::GetPropertyAccessor() { +base::PropertyAccessor<HtmlDialogUIDelegate*>& + HtmlDialogUI::GetPropertyAccessor() { return g_html_dialog_ui_property_accessor.Get(); } diff --git a/chrome/browser/ui/webui/html_dialog_ui.h b/chrome/browser/ui/webui/html_dialog_ui.h index 9e26f85..390790d 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.h +++ b/chrome/browser/ui/webui/html_dialog_ui.h @@ -11,17 +11,17 @@ #include "base/string16.h" #include "chrome/browser/ui/webui/chrome_web_ui.h" -#include "content/common/property_bag.h" #include "googleurl/src/gurl.h" -namespace gfx { -class Size; -} - struct ContextMenuParams; namespace base { class ListValue; +template<class T> class PropertyAccessor; +} + +namespace gfx { +class Size; } // Implement this class to receive notifications. @@ -105,7 +105,7 @@ class HtmlDialogUI : public ChromeWebUI { // Returns the PropertyBag accessor object used to write the delegate pointer // into the TabContents (see class-level comment above). - static PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); + static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); private: // WebUI diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 8552d4d..2ed1e50 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -14,10 +14,10 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/process_util.h" +#include "base/property_bag.h" #include "base/string16.h" #include "base/timer.h" #include "content/common/content_export.h" -#include "content/common/property_bag.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/common/page_zoom.h" #include "ipc/ipc_channel.h" @@ -166,8 +166,8 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // Returns the property bag for this widget, where callers can add extra data // they may wish to associate with it. Returns a pointer rather than a // reference since the PropertyAccessors expect this. - const PropertyBag* property_bag() const { return &property_bag_; } - PropertyBag* property_bag() { return &property_bag_; } + const base::PropertyBag* property_bag() const { return &property_bag_; } + base::PropertyBag* property_bag() { return &property_bag_; } // Called when a renderer object already been created for this host, and we // just need to be attached to it. Used for window.open, <select> dropdown @@ -631,7 +631,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, content::RenderProcessHost* process_; // Stores random bits of data for others to associate with this object. - PropertyBag property_bag_; + base::PropertyBag property_bag_; // The ID of the corresponding object in the Renderer Instance. int routing_id_; diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 9f7dd31..846a8f5 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -14,6 +14,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" +#include "base/property_bag.h" #include "base/string16.h" #include "content/browser/download/save_package.h" #include "content/browser/javascript_dialogs.h" @@ -26,7 +27,6 @@ #include "content/browser/tab_contents/tab_contents_observer.h" #include "content/browser/webui/web_ui.h" #include "content/common/content_export.h" -#include "content/common/property_bag.h" #include "content/public/common/renderer_preferences.h" #include "net/base/load_states.h" #include "ui/gfx/native_widget_types.h" @@ -87,8 +87,8 @@ class CONTENT_EXPORT TabContents : public PageNavigator, // Returns the property bag for this tab contents, where callers can add // extra data they may wish to associate with the tab. Returns a pointer // rather than a reference since the PropertyAccessors expect this. - const PropertyBag* property_bag() const { return &property_bag_; } - PropertyBag* property_bag() { return &property_bag_; } + const base::PropertyBag* property_bag() const { return &property_bag_; } + base::PropertyBag* property_bag() { return &property_bag_; } TabContentsDelegate* delegate() const { return delegate_; } void set_delegate(TabContentsDelegate* delegate); @@ -734,7 +734,7 @@ class CONTENT_EXPORT TabContents : public PageNavigator, // Stores random bits of data for others to associate with this object. // WARNING: this needs to be deleted after NavigationController. - PropertyBag property_bag_; + base::PropertyBag property_bag_; // Data for core operation --------------------------------------------------- diff --git a/content/content_common.gypi b/content/content_common.gypi index 15c0201..9471689 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -209,8 +209,6 @@ 'common/process_watcher_mac.cc', 'common/process_watcher_posix.cc', 'common/process_watcher_win.cc', - 'common/property_bag.cc', - 'common/property_bag.h', 'common/quota_messages.h', 'common/quota_dispatcher.cc', 'common/quota_dispatcher.h', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index e95c636..aa97203 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -227,7 +227,6 @@ 'common/net/url_fetcher_impl_unittest.cc', 'common/page_zoom_unittest.cc', 'common/process_watcher_unittest.cc', - 'common/property_bag_unittest.cc', 'common/resource_dispatcher_unittest.cc', 'gpu/gpu_info_collector_unittest.cc', 'gpu/gpu_info_collector_unittest_win.cc', |