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

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: Pure merge 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 13 matching lines...) Expand all
43 class AutofillProfileSyncableService 44 class AutofillProfileSyncableService
44 : public base::SupportsUserData::Data, 45 : public base::SupportsUserData::Data,
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 CreateForWebDataServiceAndBackend(
54 autofill::AutofillWebDataService* web_data_service, 55 autofill::AutofillWebDataService* web_data_service,
56 autofill::AutofillWebDataBackend* 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(
(...skipping 12 matching lines...) Expand all
77 virtual void AutofillProfileChanged( 79 virtual void AutofillProfileChanged(
78 const autofill::AutofillProfileChange& change) OVERRIDE; 80 const autofill::AutofillProfileChange& change) OVERRIDE;
79 81
80 // Provides a StartSyncFlare to the SyncableService. See 82 // Provides a StartSyncFlare to the SyncableService. See
81 // sync_start_util for more. 83 // sync_start_util for more.
82 void InjectStartSyncFlare( 84 void InjectStartSyncFlare(
83 const syncer::SyncableService::StartSyncFlare& flare); 85 const syncer::SyncableService::StartSyncFlare& flare);
84 86
85 protected: 87 protected:
86 AutofillProfileSyncableService( 88 AutofillProfileSyncableService(
87 autofill::AutofillWebDataService* web_data_service, 89 autofill::AutofillWebDataBackend* webdata_backend,
88 const std::string& app_locale); 90 const std::string& app_locale);
89 91
90 // A convenience wrapper of a bunch of state we pass around while 92 // A convenience wrapper of a bunch of state we pass around while
91 // associating models, and send to the WebDatabase for persistence. 93 // associating models, and send to the WebDatabase for persistence.
92 // We do this so we hold the write lock for only a small period. 94 // We do this so we hold the write lock for only a small period.
93 // When storing the web db we are out of the write lock. 95 // When storing the web db we are out of the write lock.
94 struct DataBundle; 96 struct DataBundle;
95 97
96 // Helper to query WebDatabase for the current autofill state. 98 // Helper to query WebDatabase for the current autofill state.
97 // Made virtual for ease of mocking in the unit-test. 99 // Made virtual for ease of mocking in the unit-test.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 static bool MergeProfile(const autofill::AutofillProfile& merge_from, 178 static bool MergeProfile(const autofill::AutofillProfile& merge_from,
177 autofill::AutofillProfile* merge_into, 179 autofill::AutofillProfile* merge_into,
178 const std::string& app_locale); 180 const std::string& app_locale);
179 181
180 // For unit-tests. 182 // For unit-tests.
181 AutofillProfileSyncableService(); 183 AutofillProfileSyncableService();
182 void set_sync_processor(syncer::SyncChangeProcessor* sync_processor) { 184 void set_sync_processor(syncer::SyncChangeProcessor* sync_processor) {
183 sync_processor_.reset(sync_processor); 185 sync_processor_.reset(sync_processor);
184 } 186 }
185 187
186 autofill::AutofillWebDataService* web_data_service_; // WEAK 188 autofill::AutofillWebDataBackend* webdata_backend_; // WEAK
187 std::string app_locale_; 189 std::string app_locale_;
188 ScopedObserver<autofill::AutofillWebDataService, 190 ScopedObserver<autofill::AutofillWebDataBackend,
189 AutofillProfileSyncableService> scoped_observer_; 191 AutofillProfileSyncableService> scoped_observer_;
190 192
191 // Cached Autofill profiles. *Warning* deleted profiles are still in the 193 // Cached Autofill profiles. *Warning* deleted profiles are still in the
192 // vector - use the |profiles_map_| to iterate through actual profiles. 194 // vector - use the |profiles_map_| to iterate through actual profiles.
193 ScopedVector<autofill::AutofillProfile> profiles_; 195 ScopedVector<autofill::AutofillProfile> profiles_;
194 GUIDToProfileMap profiles_map_; 196 GUIDToProfileMap profiles_map_;
195 197
196 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 198 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
197 199
198 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; 200 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
(...skipping 13 matching lines...) Expand all
212 std::vector<autofill::AutofillProfile*> profiles_to_add; 214 std::vector<autofill::AutofillProfile*> profiles_to_add;
213 215
214 // When we go through sync we find profiles that are similar but unmatched. 216 // When we go through sync we find profiles that are similar but unmatched.
215 // Merge such profiles. 217 // Merge such profiles.
216 GUIDToProfileMap candidates_to_merge; 218 GUIDToProfileMap candidates_to_merge;
217 // Profiles that have multi-valued fields that are not in sync. 219 // Profiles that have multi-valued fields that are not in sync.
218 std::vector<autofill::AutofillProfile*> profiles_to_sync_back; 220 std::vector<autofill::AutofillProfile*> profiles_to_sync_back;
219 }; 221 };
220 222
221 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 223 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autocomplete_syncable_service.cc ('k') | chrome/browser/webdata/autofill_profile_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698