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

Side by Side Diff: chrome/browser/webdata/autofill_profile_syncable_service.h

Issue 14081043: Hook up Autofill Backend interface to SyncableServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update interface 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 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 4 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
5 #define CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 5 #define CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "base/supports_user_data.h" 14 #include "base/supports_user_data.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "components/autofill/browser/autofill_type.h" 17 #include "components/autofill/browser/autofill_type.h"
18 #include "components/autofill/browser/webdata/autofill_change.h" 18 #include "components/autofill/browser/webdata/autofill_change.h"
19 #include "components/autofill/browser/webdata/autofill_entry.h" 19 #include "components/autofill/browser/webdata/autofill_entry.h"
20 #include "components/autofill/browser/webdata/autofill_webdata_backend.h"
20 #include "components/autofill/browser/webdata/autofill_webdata_service_observer. h" 21 #include "components/autofill/browser/webdata/autofill_webdata_service_observer. h"
21 #include "sync/api/sync_change.h" 22 #include "sync/api/sync_change.h"
22 #include "sync/api/sync_data.h" 23 #include "sync/api/sync_data.h"
23 #include "sync/api/sync_error.h" 24 #include "sync/api/sync_error.h"
24 #include "sync/api/syncable_service.h" 25 #include "sync/api/syncable_service.h"
25 #include "sync/protocol/autofill_specifics.pb.h" 26 #include "sync/protocol/autofill_specifics.pb.h"
26 27
27 class ProfileSyncServiceAutofillTest; 28 class ProfileSyncServiceAutofillTest;
28 class WebDataServiceBase; 29 class WebDataServiceBase;
29 30
(...skipping 15 matching lines...) Expand all
45 public syncer::SyncableService, 46 public syncer::SyncableService,
46 public autofill::AutofillWebDataServiceObserverOnDBThread, 47 public autofill::AutofillWebDataServiceObserverOnDBThread,
47 public base::NonThreadSafe { 48 public base::NonThreadSafe {
48 public: 49 public:
49 virtual ~AutofillProfileSyncableService(); 50 virtual ~AutofillProfileSyncableService();
50 51
51 // Creates a new AutofillProfileSyncableService and hangs it off of 52 // Creates a new AutofillProfileSyncableService and hangs it off of
52 // |web_data_service|, which takes ownership. 53 // |web_data_service|, which takes ownership.
53 static void CreateForWebDataService( 54 static void CreateForWebDataService(
54 autofill::AutofillWebDataService* web_data_service, 55 autofill::AutofillWebDataService* web_data_service,
56 autofill::AutofillWebDataBackend* autofill_webdata_backend,
55 const std::string& app_locale); 57 const std::string& app_locale);
56 58
57 // Retrieves the AutofillProfileSyncableService stored on |web_data_service|. 59 // Retrieves the AutofillProfileSyncableService stored on |web_data_service|.
58 static AutofillProfileSyncableService* FromWebDataService( 60 static AutofillProfileSyncableService* FromWebDataService(
59 autofill::AutofillWebDataService* web_data_service); 61 autofill::AutofillWebDataService* web_data_service);
60 62
61 static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; } 63 static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; }
62 64
63 // syncer::SyncableService implementation. 65 // syncer::SyncableService implementation.
64 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( 66 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
65 syncer::ModelType type, 67 syncer::ModelType type,
66 const syncer::SyncDataList& initial_sync_data, 68 const syncer::SyncDataList& initial_sync_data,
67 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 69 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
68 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE; 70 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
69 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; 71 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
70 virtual syncer::SyncDataList GetAllSyncData( 72 virtual syncer::SyncDataList GetAllSyncData(
71 syncer::ModelType type) const OVERRIDE; 73 syncer::ModelType type) const OVERRIDE;
72 virtual syncer::SyncError ProcessSyncChanges( 74 virtual syncer::SyncError ProcessSyncChanges(
73 const tracked_objects::Location& from_here, 75 const tracked_objects::Location& from_here,
74 const syncer::SyncChangeList& change_list) OVERRIDE; 76 const syncer::SyncChangeList& change_list) OVERRIDE;
75 77
76 // AutofillWebDataServiceObserverOnDBThread implementation. 78 // AutofillWebDataServiceObserverOnDBThread implementation.
77 virtual void AutofillProfileChanged( 79 virtual void AutofillProfileChanged(
78 const autofill::AutofillProfileChange& change) OVERRIDE; 80 const autofill::AutofillProfileChange& change) OVERRIDE;
79 81
80 protected: 82 protected:
81 AutofillProfileSyncableService( 83 AutofillProfileSyncableService(
82 autofill::AutofillWebDataService* web_data_service, 84 autofill::AutofillWebDataBackend* autofill_webdata_backend,
83 const std::string& app_locale); 85 const std::string& app_locale);
84 86
85 // A convenience wrapper of a bunch of state we pass around while 87 // A convenience wrapper of a bunch of state we pass around while
86 // associating models, and send to the WebDatabase for persistence. 88 // associating models, and send to the WebDatabase for persistence.
87 // We do this so we hold the write lock for only a small period. 89 // We do this so we hold the write lock for only a small period.
88 // When storing the web db we are out of the write lock. 90 // When storing the web db we are out of the write lock.
89 struct DataBundle; 91 struct DataBundle;
90 92
91 // Helper to query WebDatabase for the current autofill state. 93 // Helper to query WebDatabase for the current autofill state.
92 // Made virtual for ease of mocking in the unit-test. 94 // Made virtual for ease of mocking in the unit-test.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 static bool MergeProfile(const autofill::AutofillProfile& merge_from, 173 static bool MergeProfile(const autofill::AutofillProfile& merge_from,
172 autofill::AutofillProfile* merge_into, 174 autofill::AutofillProfile* merge_into,
173 const std::string& app_locale); 175 const std::string& app_locale);
174 176
175 // For unit-tests. 177 // For unit-tests.
176 AutofillProfileSyncableService(); 178 AutofillProfileSyncableService();
177 void set_sync_processor(syncer::SyncChangeProcessor* sync_processor) { 179 void set_sync_processor(syncer::SyncChangeProcessor* sync_processor) {
178 sync_processor_.reset(sync_processor); 180 sync_processor_.reset(sync_processor);
179 } 181 }
180 182
181 autofill::AutofillWebDataService* web_data_service_; // WEAK 183 autofill::AutofillWebDataBackend* autofill_webdata_backend_; // WEAK
Ilya Sherman 2013/05/13 23:44:47 nit: Perhaps just "webdata_backend_"?
Cait (Slow) 2013/05/14 22:30:08 Done.
182 std::string app_locale_; 184 std::string app_locale_;
183 ScopedObserver<autofill::AutofillWebDataService, 185 ScopedObserver<autofill::AutofillWebDataBackend,
184 AutofillProfileSyncableService> scoped_observer_; 186 AutofillProfileSyncableService> scoped_observer_;
185 187
186 // Cached Autofill profiles. *Warning* deleted profiles are still in the 188 // Cached Autofill profiles. *Warning* deleted profiles are still in the
187 // vector - use the |profiles_map_| to iterate through actual profiles. 189 // vector - use the |profiles_map_| to iterate through actual profiles.
188 ScopedVector<autofill::AutofillProfile> profiles_; 190 ScopedVector<autofill::AutofillProfile> profiles_;
189 GUIDToProfileMap profiles_map_; 191 GUIDToProfileMap profiles_map_;
190 192
191 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 193 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
192 194
193 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; 195 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
(...skipping 11 matching lines...) Expand all
205 std::vector<autofill::AutofillProfile*> profiles_to_add; 207 std::vector<autofill::AutofillProfile*> profiles_to_add;
206 208
207 // When we go through sync we find profiles that are similar but unmatched. 209 // When we go through sync we find profiles that are similar but unmatched.
208 // Merge such profiles. 210 // Merge such profiles.
209 GUIDToProfileMap candidates_to_merge; 211 GUIDToProfileMap candidates_to_merge;
210 // Profiles that have multi-valued fields that are not in sync. 212 // Profiles that have multi-valued fields that are not in sync.
211 std::vector<autofill::AutofillProfile*> profiles_to_sync_back; 213 std::vector<autofill::AutofillProfile*> profiles_to_sync_back;
212 }; 214 };
213 215
214 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 216 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698