OLD | NEW |
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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "sync/api/sync_data.h" | 22 #include "sync/api/sync_data.h" |
23 #include "sync/api/sync_error.h" | 23 #include "sync/api/sync_error.h" |
24 #include "sync/api/syncable_service.h" | 24 #include "sync/api/syncable_service.h" |
25 #include "sync/protocol/autofill_specifics.pb.h" | 25 #include "sync/protocol/autofill_specifics.pb.h" |
26 | 26 |
27 class AutofillProfile; | 27 class AutofillProfile; |
28 class AutofillTable; | 28 class AutofillTable; |
29 class FormGroup; | 29 class FormGroup; |
30 class ProfileSyncServiceAutofillTest; | 30 class ProfileSyncServiceAutofillTest; |
31 class WebDataService; | 31 class WebDataService; |
| 32 class WebDataServiceBase; |
32 | 33 |
33 extern const char kAutofillProfileTag[]; | 34 extern const char kAutofillProfileTag[]; |
34 | 35 |
35 // The sync implementation for AutofillProfiles. | 36 // The sync implementation for AutofillProfiles. |
36 // MergeDataAndStartSyncing() called first, it does cloud->local and | 37 // MergeDataAndStartSyncing() called first, it does cloud->local and |
37 // local->cloud syncs. Then for each cloud change we receive | 38 // local->cloud syncs. Then for each cloud change we receive |
38 // ProcessSyncChanges() and for each local change Observe() is called. | 39 // ProcessSyncChanges() and for each local change Observe() is called. |
39 class AutofillProfileSyncableService | 40 class AutofillProfileSyncableService |
40 : public syncer::SyncableService, | 41 : public syncer::SyncableService, |
41 public content::NotificationObserver, | 42 public content::NotificationObserver, |
42 public base::NonThreadSafe { | 43 public base::NonThreadSafe { |
43 public: | 44 public: |
44 explicit AutofillProfileSyncableService(WebDataService* web_data_service); | 45 explicit AutofillProfileSyncableService(WebDataService* web_data_service); |
45 virtual ~AutofillProfileSyncableService(); | 46 virtual ~AutofillProfileSyncableService(); |
46 | 47 |
| 48 // Retrieves the AutofillProfileSyncableService stored on |web_data|. |
| 49 static AutofillProfileSyncableService* FromWebData( |
| 50 WebDataServiceBase* web_data); |
| 51 |
| 52 // Attaches |service| to |web_data|, transferring ownership to |web_data|. |
| 53 static void AttachToWebData( |
| 54 scoped_ptr<AutofillProfileSyncableService> service, |
| 55 WebDataServiceBase* web_data); |
| 56 |
47 static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; } | 57 static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; } |
48 | 58 |
49 // syncer::SyncableService implementation. | 59 // syncer::SyncableService implementation. |
50 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 60 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( |
51 syncer::ModelType type, | 61 syncer::ModelType type, |
52 const syncer::SyncDataList& initial_sync_data, | 62 const syncer::SyncDataList& initial_sync_data, |
53 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 63 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
54 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE; | 64 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE; |
55 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 65 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
56 virtual syncer::SyncDataList GetAllSyncData( | 66 virtual syncer::SyncDataList GetAllSyncData( |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 std::vector<AutofillProfile*> profiles_to_add; | 192 std::vector<AutofillProfile*> profiles_to_add; |
183 | 193 |
184 // When we go through sync we find profiles that are similar but unmatched. | 194 // When we go through sync we find profiles that are similar but unmatched. |
185 // Merge such profiles. | 195 // Merge such profiles. |
186 GUIDToProfileMap candidates_to_merge; | 196 GUIDToProfileMap candidates_to_merge; |
187 // Profiles that have multi-valued fields that are not in sync. | 197 // Profiles that have multi-valued fields that are not in sync. |
188 std::vector<AutofillProfile*> profiles_to_sync_back; | 198 std::vector<AutofillProfile*> profiles_to_sync_back; |
189 }; | 199 }; |
190 | 200 |
191 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ | 201 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ |
OLD | NEW |