Index: components/autofill/browser/webdata/autofill_webdata_service.h |
diff --git a/components/autofill/browser/webdata/autofill_webdata_service.h b/components/autofill/browser/webdata/autofill_webdata_service.h |
index 07cb25a82ea5dd5761479563299d068cae1fa4b8..bfa9d5843abdf22e6f3dc8efc71ce309e5f5003a 100644 |
--- a/components/autofill/browser/webdata/autofill_webdata_service.h |
+++ b/components/autofill/browser/webdata/autofill_webdata_service.h |
@@ -9,6 +9,7 @@ |
#include "base/memory/ref_counted.h" |
#include "base/observer_list.h" |
+#include "base/supports_user_data.h" |
#include "components/autofill/browser/webdata/autofill_webdata.h" |
#include "components/autofill/common/form_field_data.h" |
#include "components/webdata/common/web_data_results.h" |
@@ -52,6 +53,9 @@ class AutofillWebDataService : public AutofillWebData, |
static void NotifyOfMultipleAutofillChanges( |
AutofillWebDataService* web_data_service); |
+ // WebDataServiceBase implementation. |
+ virtual void ShutdownOnUIThread() OVERRIDE; |
+ |
// AutofillWebData implementation. |
virtual void AddFormFields( |
const std::vector<FormFieldData>& fields) OVERRIDE; |
@@ -85,9 +89,17 @@ class AutofillWebDataService : public AutofillWebData, |
void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
+ // Returns a SupportsUserData objects that may be used to store data |
+ // owned by the DB thread on this object. Should be called only from |
+ // the DB thread, and will be destroyed on the DB thread soon after |
+ // |ShutdownOnUIThread()| is called. |
+ base::SupportsUserData* GetDBUserData(); |
+ |
protected: |
virtual ~AutofillWebDataService(); |
+ virtual void ShutdownOnDBThread(); |
+ |
private: |
WebDatabase::State AddFormElementsImpl( |
const std::vector<FormFieldData>& fields, WebDatabase* db); |
@@ -125,6 +137,23 @@ class AutofillWebDataService : public AutofillWebData, |
void NotifyAutofillMultipleChangedOnUIThread(); |
+ // This makes the destructor public, and thus allows us to aggregate |
+ // SupportsUserData. It is private by default to prevent incorrect |
+ // usage in class hierarchies where it is inherited by |
+ // reference-counted objects. |
+ class SupportsUserDataAggregatable : public base::SupportsUserData { |
+ public: |
+ SupportsUserDataAggregatable() {} |
+ virtual ~SupportsUserDataAggregatable() {} |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); |
+ }; |
+ |
+ // Storage for user data to be accessed only on the DB thread. May |
+ // be used e.g. for SyncableService subclasses that need to be owned |
+ // by this object. Is created on first call to |GetDBUserData()|. |
+ scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; |
+ |
ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; |
ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; |