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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "base/supports_user_data.h"
12 #include "components/autofill/browser/webdata/autofill_webdata.h" 13 #include "components/autofill/browser/webdata/autofill_webdata.h"
13 #include "components/autofill/common/form_field_data.h" 14 #include "components/autofill/common/form_field_data.h"
14 #include "components/webdata/common/web_data_results.h" 15 #include "components/webdata/common/web_data_results.h"
15 #include "components/webdata/common/web_data_service_base.h" 16 #include "components/webdata/common/web_data_service_base.h"
16 #include "components/webdata/common/web_data_service_consumer.h" 17 #include "components/webdata/common/web_data_service_consumer.h"
17 #include "components/webdata/common/web_database.h" 18 #include "components/webdata/common/web_database.h"
18 19
19 class WebDatabaseService; 20 class WebDatabaseService;
20 21
21 namespace content { 22 namespace content {
(...skipping 23 matching lines...) Expand all
45 content::BrowserContext* context); 46 content::BrowserContext* context);
46 47
47 // Notifies listeners on the UI thread that multiple changes have been made to 48 // Notifies listeners on the UI thread that multiple changes have been made to
48 // to Autofill records of the database. 49 // to Autofill records of the database.
49 // NOTE: This method is intended to be called from the DB thread. It 50 // NOTE: This method is intended to be called from the DB thread. It
50 // it asynchronously notifies listeners on the UI thread. 51 // it asynchronously notifies listeners on the UI thread.
51 // |web_data_service| may be NULL for testing purposes. 52 // |web_data_service| may be NULL for testing purposes.
52 static void NotifyOfMultipleAutofillChanges( 53 static void NotifyOfMultipleAutofillChanges(
53 AutofillWebDataService* web_data_service); 54 AutofillWebDataService* web_data_service);
54 55
56 // WebDataServiceBase implementation.
57 virtual void ShutdownOnUIThread() OVERRIDE;
58
55 // AutofillWebData implementation. 59 // AutofillWebData implementation.
56 virtual void AddFormFields( 60 virtual void AddFormFields(
57 const std::vector<FormFieldData>& fields) OVERRIDE; 61 const std::vector<FormFieldData>& fields) OVERRIDE;
58 virtual WebDataServiceBase::Handle GetFormValuesForElementName( 62 virtual WebDataServiceBase::Handle GetFormValuesForElementName(
59 const base::string16& name, 63 const base::string16& name,
60 const base::string16& prefix, 64 const base::string16& prefix,
61 int limit, 65 int limit,
62 WebDataServiceConsumer* consumer) OVERRIDE; 66 WebDataServiceConsumer* consumer) OVERRIDE;
63 virtual void RemoveFormElementsAddedBetween( 67 virtual void RemoveFormElementsAddedBetween(
64 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; 68 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE;
(...skipping 13 matching lines...) Expand all
78 WebDataServiceConsumer* consumer) OVERRIDE; 82 WebDataServiceConsumer* consumer) OVERRIDE;
79 virtual void RemoveAutofillDataModifiedBetween( 83 virtual void RemoveAutofillDataModifiedBetween(
80 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; 84 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE;
81 85
82 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); 86 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer);
83 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); 87 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer);
84 88
85 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); 89 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer);
86 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); 90 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer);
87 91
92 // Returns a SupportsUserData objects that may be used to store data
93 // owned by the DB thread on this object. Should be called only from
94 // the DB thread, and will be destroyed on the DB thread soon after
95 // |ShutdownOnUIThread()| is called.
96 base::SupportsUserData* GetDBUserData();
97
88 protected: 98 protected:
89 virtual ~AutofillWebDataService(); 99 virtual ~AutofillWebDataService();
90 100
101 virtual void ShutdownOnDBThread();
102
91 private: 103 private:
92 WebDatabase::State AddFormElementsImpl( 104 WebDatabase::State AddFormElementsImpl(
93 const std::vector<FormFieldData>& fields, WebDatabase* db); 105 const std::vector<FormFieldData>& fields, WebDatabase* db);
94 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl( 106 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl(
95 const base::string16& name, const base::string16& prefix, int limit, 107 const base::string16& name, const base::string16& prefix, int limit,
96 WebDatabase* db); 108 WebDatabase* db);
97 WebDatabase::State RemoveFormElementsAddedBetweenImpl( 109 WebDatabase::State RemoveFormElementsAddedBetweenImpl(
98 const base::Time& delete_begin, const base::Time& delete_end, 110 const base::Time& delete_begin, const base::Time& delete_end,
99 WebDatabase* db); 111 WebDatabase* db);
100 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); 112 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db);
(...skipping 17 matching lines...) Expand all
118 const base::Time& delete_begin, const base::Time& delete_end, 130 const base::Time& delete_begin, const base::Time& delete_end,
119 WebDatabase* db); 131 WebDatabase* db);
120 132
121 // Callbacks to ensure that sensitive info is destroyed if request is 133 // Callbacks to ensure that sensitive info is destroyed if request is
122 // cancelled. 134 // cancelled.
123 void DestroyAutofillProfileResult(const WDTypedResult* result); 135 void DestroyAutofillProfileResult(const WDTypedResult* result);
124 void DestroyAutofillCreditCardResult(const WDTypedResult* result); 136 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
125 137
126 void NotifyAutofillMultipleChangedOnUIThread(); 138 void NotifyAutofillMultipleChangedOnUIThread();
127 139
140 // This makes the destructor public, and thus allows us to aggregate
141 // SupportsUserData. It is private by default to prevent incorrect
142 // usage in class hierarchies where it is inherited by
143 // reference-counted objects.
144 class SupportsUserDataAggregatable : public base::SupportsUserData {
145 public:
146 SupportsUserDataAggregatable() {}
147 virtual ~SupportsUserDataAggregatable() {}
148 private:
149 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable);
150 };
151
152 // Storage for user data to be accessed only on the DB thread. May
153 // be used e.g. for SyncableService subclasses that need to be owned
154 // by this object. Is created on first call to |GetDBUserData()|.
155 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_;
156
128 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; 157 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_;
129 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; 158 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_;
130 159
131 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); 160 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService);
132 }; 161 };
133 162
134 } // namespace autofill 163 } // namespace autofill
135 164
136 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 165 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698