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

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

Issue 12494020: Remove knowledge of Chrome-specific SyncableService classes from WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECK. Created 7 years, 9 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/supports_user_data.h"
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
15 #include "chrome/browser/webdata/autofill_change.h" 16 #include "chrome/browser/webdata/autofill_change.h"
16 #include "chrome/browser/webdata/autofill_entry.h" 17 #include "chrome/browser/webdata/autofill_entry.h"
17 #include "components/autofill/browser/autofill_type.h" 18 #include "components/autofill/browser/autofill_type.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.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 AutofillProfile; 28 class AutofillProfile;
28 class AutofillTable; 29 class AutofillTable;
29 class FormGroup; 30 class FormGroup;
30 class ProfileSyncServiceAutofillTest; 31 class ProfileSyncServiceAutofillTest;
31 class WebDataService; 32 class WebDataService;
33 class WebDataServiceBase;
32 34
33 extern const char kAutofillProfileTag[]; 35 extern const char kAutofillProfileTag[];
34 36
35 // The sync implementation for AutofillProfiles. 37 // The sync implementation for AutofillProfiles.
36 // MergeDataAndStartSyncing() called first, it does cloud->local and 38 // MergeDataAndStartSyncing() called first, it does cloud->local and
37 // local->cloud syncs. Then for each cloud change we receive 39 // local->cloud syncs. Then for each cloud change we receive
38 // ProcessSyncChanges() and for each local change Observe() is called. 40 // ProcessSyncChanges() and for each local change Observe() is called.
39 class AutofillProfileSyncableService 41 class AutofillProfileSyncableService
40 : public syncer::SyncableService, 42 : public base::SupportsUserData::Data,
43 public syncer::SyncableService,
41 public content::NotificationObserver, 44 public content::NotificationObserver,
42 public base::NonThreadSafe { 45 public base::NonThreadSafe {
43 public: 46 public:
44 explicit AutofillProfileSyncableService(WebDataService* web_data_service);
45 virtual ~AutofillProfileSyncableService(); 47 virtual ~AutofillProfileSyncableService();
46 48
49 // TODO(joi): Change this to key off AutofillWebDataService instead
50 // of WebDataService, once it is truly separate.
51
52 // Creates a new AutofillProfileSyncableService and hangs it off of
53 // |web_data|, which takes ownership.
54 static void CreateForWebDataService(WebDataService* web_data);
55 // Retrieves the AutofillProfileSyncableService stored on |web_data|.
56 static AutofillProfileSyncableService* FromWebDataService(
57 WebDataService* web_data);
58
47 static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; } 59 static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; }
48 60
49 // syncer::SyncableService implementation. 61 // syncer::SyncableService implementation.
50 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( 62 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
51 syncer::ModelType type, 63 syncer::ModelType type,
52 const syncer::SyncDataList& initial_sync_data, 64 const syncer::SyncDataList& initial_sync_data,
53 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 65 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
54 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE; 66 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
55 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; 67 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
56 virtual syncer::SyncDataList GetAllSyncData( 68 virtual syncer::SyncDataList GetAllSyncData(
57 syncer::ModelType type) const OVERRIDE; 69 syncer::ModelType type) const OVERRIDE;
58 virtual syncer::SyncError ProcessSyncChanges( 70 virtual syncer::SyncError ProcessSyncChanges(
59 const tracked_objects::Location& from_here, 71 const tracked_objects::Location& from_here,
60 const syncer::SyncChangeList& change_list) OVERRIDE; 72 const syncer::SyncChangeList& change_list) OVERRIDE;
61 73
62 // content::NotificationObserver implementation. 74 // content::NotificationObserver implementation.
63 virtual void Observe(int type, 75 virtual void Observe(int type,
64 const content::NotificationSource& source, 76 const content::NotificationSource& source,
65 const content::NotificationDetails& details) OVERRIDE; 77 const content::NotificationDetails& details) OVERRIDE;
66 78
67 protected: 79 protected:
80 explicit AutofillProfileSyncableService(WebDataService* web_data_service);
81
68 // A convenience wrapper of a bunch of state we pass around while 82 // A convenience wrapper of a bunch of state we pass around while
69 // associating models, and send to the WebDatabase for persistence. 83 // associating models, and send to the WebDatabase for persistence.
70 // We do this so we hold the write lock for only a small period. 84 // We do this so we hold the write lock for only a small period.
71 // When storing the web db we are out of the write lock. 85 // When storing the web db we are out of the write lock.
72 struct DataBundle; 86 struct DataBundle;
73 87
74 // Helper to query WebDatabase for the current autofill state. 88 // Helper to query WebDatabase for the current autofill state.
75 // Made virtual for ease of mocking in the unit-test. 89 // Made virtual for ease of mocking in the unit-test.
76 // Caller owns returned |profiles|. 90 // Caller owns returned |profiles|.
77 virtual bool LoadAutofillData(std::vector<AutofillProfile*>* profiles); 91 virtual bool LoadAutofillData(std::vector<AutofillProfile*>* profiles);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 std::vector<AutofillProfile*> profiles_to_add; 196 std::vector<AutofillProfile*> profiles_to_add;
183 197
184 // When we go through sync we find profiles that are similar but unmatched. 198 // When we go through sync we find profiles that are similar but unmatched.
185 // Merge such profiles. 199 // Merge such profiles.
186 GUIDToProfileMap candidates_to_merge; 200 GUIDToProfileMap candidates_to_merge;
187 // Profiles that have multi-valued fields that are not in sync. 201 // Profiles that have multi-valued fields that are not in sync.
188 std::vector<AutofillProfile*> profiles_to_sync_back; 202 std::vector<AutofillProfile*> profiles_to_sync_back;
189 }; 203 };
190 204
191 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 205 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698