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

Unified Diff: components/autofill/browser/webdata/autofill_webdata_service.h

Issue 13898011: Move SupportsUserData code into AutofillWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and test fix Created 7 years, 8 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: 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_;

Powered by Google App Engine
This is Rietveld 408576698