OLD | NEW |
---|---|
1 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ | 1 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ |
2 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ | 2 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ |
3 | 3 |
4 #include "base/memory/ref_counted.h" | 4 #include "base/memory/ref_counted.h" |
5 #include "base/memory/weak_ptr.h" | |
5 #include "base/observer_list.h" | 6 #include "base/observer_list.h" |
6 #include "components/autofill/browser/webdata/autofill_webdata.h" | 7 #include "components/autofill/browser/webdata/autofill_webdata.h" |
8 #include "components/autofill/browser/webdata/autofill_webdata_service.h" | |
7 #include "components/autofill/common/form_field_data.h" | 9 #include "components/autofill/common/form_field_data.h" |
8 #include "components/webdata/common/web_data_results.h" | 10 #include "components/webdata/common/web_data_results.h" |
9 #include "components/webdata/common/web_data_service_base.h" | 11 #include "components/webdata/common/web_data_service_base.h" |
10 #include "components/webdata/common/web_data_service_consumer.h" | 12 #include "components/webdata/common/web_data_service_consumer.h" |
11 #include "components/webdata/common/web_database.h" | 13 #include "components/webdata/common/web_database.h" |
12 | 14 |
13 namespace autofill { | 15 namespace autofill { |
14 | 16 |
17 class AutofillBackendDelegate; | |
15 class AutofillChange; | 18 class AutofillChange; |
16 class AutofillProfile; | 19 class AutofillProfile; |
17 class AutofillWebDataServiceObserverOnDBThread; | 20 class AutofillWebDataServiceObserverOnDBThread; |
18 class CreditCard; | 21 class CreditCard; |
19 | 22 |
20 class AutofillWebDataBackend | 23 class AutofillWebDataBackend |
21 : public base::RefCountedThreadSafe<AutofillWebDataBackend, | 24 : public base::RefCountedThreadSafe<AutofillWebDataBackend, |
22 content::BrowserThread::DeleteOnDBThread> { | 25 content::BrowserThread::DeleteOnDBThread> { |
23 public: | 26 public: |
24 AutofillWebDataBackend(); | 27 AutofillWebDataBackend(); |
(...skipping 23 matching lines...) Expand all Loading... | |
48 WebDatabase::State RemoveCreditCardImpl( | 51 WebDatabase::State RemoveCreditCardImpl( |
49 const std::string& guid, WebDatabase* db); | 52 const std::string& guid, WebDatabase* db); |
50 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); | 53 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); |
51 WebDatabase::State RemoveAutofillDataModifiedBetweenImpl( | 54 WebDatabase::State RemoveAutofillDataModifiedBetweenImpl( |
52 const base::Time& delete_begin, const base::Time& delete_end, | 55 const base::Time& delete_begin, const base::Time& delete_end, |
53 WebDatabase* db); | 56 WebDatabase* db); |
54 | 57 |
55 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); | 58 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); |
56 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); | 59 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); |
57 | 60 |
61 // Initializes |delegate_| if it has not already been initialized, and returns | |
62 // a ptr to it asynchonously via |callback|. | |
63 void GetDelegate( | |
64 const AutofillWebDataService::DelegateOnDBCallback& callback, | |
65 base::WeakPtr<WebDatabase> db); | |
66 | |
58 protected: | 67 protected: |
59 virtual ~AutofillWebDataBackend(); | 68 virtual ~AutofillWebDataBackend(); |
60 | 69 |
61 private: | 70 private: |
62 friend struct content::BrowserThread::DeleteOnThread< | 71 friend struct content::BrowserThread::DeleteOnThread< |
63 content::BrowserThread::DB>; | 72 content::BrowserThread::DB>; |
64 friend class base::DeleteHelper<AutofillWebDataBackend>; | 73 friend class base::DeleteHelper<AutofillWebDataBackend>; |
65 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250). | 74 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250). |
66 friend class base::RefCountedThreadSafe<AutofillWebDataBackend, | 75 friend class base::RefCountedThreadSafe<AutofillWebDataBackend, |
67 content::BrowserThread::DeleteOnDBThread>; | 76 content::BrowserThread::DeleteOnDBThread>; |
68 | 77 |
69 // Callbacks to ensure that sensitive info is destroyed if request is | 78 // Callbacks to ensure that sensitive info is destroyed if request is |
70 // cancelled. | 79 // cancelled. |
71 void DestroyAutofillProfileResult(const WDTypedResult* result); | 80 void DestroyAutofillProfileResult(const WDTypedResult* result); |
72 void DestroyAutofillCreditCardResult(const WDTypedResult* result); | 81 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
73 | 82 |
74 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; | 83 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; |
75 | 84 |
85 // All vended weak pointers are invalidated in dtor(). | |
erikwright (departed)
2013/04/25 19:06:10
This comment is unnecessary (this is intrinsic in
| |
86 base::WeakPtrFactory<AutofillWebDataBackend> weak_ptr_factory_; | |
87 | |
88 // Delegate which allows clients to do autofill work directly on th DB thread. | |
89 // Owned by us. | |
90 scoped_ptr<AutofillBackendDelegate> delegate_; | |
erikwright (departed)
2013/04/25 19:06:10
Shouldn't the delegate be owned by whoever is usin
| |
91 | |
76 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend); | 92 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend); |
77 }; | 93 }; |
78 | 94 |
79 } // namespace autofill | 95 } // namespace autofill |
80 | 96 |
81 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ | 97 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ |
OLD | NEW |