| 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_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ | 4 #ifndef CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ |
| 5 #define CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ | 5 #define CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // The sync implementation for autocomplete. | 43 // The sync implementation for autocomplete. |
| 44 // MergeDataAndStartSyncing() called first, it does cloud->local and | 44 // MergeDataAndStartSyncing() called first, it does cloud->local and |
| 45 // local->cloud syncs. Then for each cloud change we receive | 45 // local->cloud syncs. Then for each cloud change we receive |
| 46 // ProcessSyncChanges() and for each local change Observe() is called. | 46 // ProcessSyncChanges() and for each local change Observe() is called. |
| 47 class AutocompleteSyncableService | 47 class AutocompleteSyncableService |
| 48 : public base::SupportsUserData::Data, | 48 : public base::SupportsUserData::Data, |
| 49 public syncer::SyncableService, | 49 public syncer::SyncableService, |
| 50 public autofill::AutofillWebDataServiceObserverOnDBThread, | 50 public autofill::AutofillWebDataServiceObserverOnDBThread, |
| 51 public base::NonThreadSafe { | 51 public base::NonThreadSafe { |
| 52 public: | 52 public: |
| 53 virtual ~AutocompleteSyncableService(); | 53 ~AutocompleteSyncableService() override; |
| 54 | 54 |
| 55 // Creates a new AutocompleteSyncableService and hangs it off of | 55 // Creates a new AutocompleteSyncableService and hangs it off of |
| 56 // |web_data_service|, which takes ownership. | 56 // |web_data_service|, which takes ownership. |
| 57 static void CreateForWebDataServiceAndBackend( | 57 static void CreateForWebDataServiceAndBackend( |
| 58 autofill::AutofillWebDataService* web_data_service, | 58 autofill::AutofillWebDataService* web_data_service, |
| 59 autofill::AutofillWebDataBackend* web_data_backend); | 59 autofill::AutofillWebDataBackend* web_data_backend); |
| 60 | 60 |
| 61 // Retrieves the AutocompleteSyncableService stored on |web_data_service|. | 61 // Retrieves the AutocompleteSyncableService stored on |web_data_service|. |
| 62 static AutocompleteSyncableService* FromWebDataService( | 62 static AutocompleteSyncableService* FromWebDataService( |
| 63 autofill::AutofillWebDataService* web_data_service); | 63 autofill::AutofillWebDataService* web_data_service); |
| 64 | 64 |
| 65 static syncer::ModelType model_type() { return syncer::AUTOFILL; } | 65 static syncer::ModelType model_type() { return syncer::AUTOFILL; } |
| 66 | 66 |
| 67 // syncer::SyncableService: | 67 // syncer::SyncableService: |
| 68 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 68 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 69 syncer::ModelType type, | 69 syncer::ModelType type, |
| 70 const syncer::SyncDataList& initial_sync_data, | 70 const syncer::SyncDataList& initial_sync_data, |
| 71 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 71 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 72 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; | 72 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 73 virtual void StopSyncing(syncer::ModelType type) override; | 73 void StopSyncing(syncer::ModelType type) override; |
| 74 virtual syncer::SyncDataList GetAllSyncData( | 74 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 75 syncer::ModelType type) const override; | 75 syncer::SyncError ProcessSyncChanges( |
| 76 virtual syncer::SyncError ProcessSyncChanges( | |
| 77 const tracked_objects::Location& from_here, | 76 const tracked_objects::Location& from_here, |
| 78 const syncer::SyncChangeList& change_list) override; | 77 const syncer::SyncChangeList& change_list) override; |
| 79 | 78 |
| 80 // AutofillWebDataServiceObserverOnDBThread: | 79 // AutofillWebDataServiceObserverOnDBThread: |
| 81 virtual void AutofillEntriesChanged( | 80 void AutofillEntriesChanged( |
| 82 const autofill::AutofillChangeList& changes) override; | 81 const autofill::AutofillChangeList& changes) override; |
| 83 | 82 |
| 84 // Provides a StartSyncFlare to the SyncableService. See sync_start_util for | 83 // Provides a StartSyncFlare to the SyncableService. See sync_start_util for |
| 85 // more. | 84 // more. |
| 86 void InjectStartSyncFlare( | 85 void InjectStartSyncFlare( |
| 87 const syncer::SyncableService::StartSyncFlare& flare); | 86 const syncer::SyncableService::StartSyncFlare& flare); |
| 88 | 87 |
| 89 protected: | 88 protected: |
| 90 explicit AutocompleteSyncableService( | 89 explicit AutocompleteSyncableService( |
| 91 autofill::AutofillWebDataBackend* web_data_backend); | 90 autofill::AutofillWebDataBackend* web_data_backend); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // We receive ownership of |error_handler_| in MergeDataAndStartSyncing() and | 168 // We receive ownership of |error_handler_| in MergeDataAndStartSyncing() and |
| 170 // destroy it in StopSyncing(). | 169 // destroy it in StopSyncing(). |
| 171 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 170 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
| 172 | 171 |
| 173 syncer::SyncableService::StartSyncFlare flare_; | 172 syncer::SyncableService::StartSyncFlare flare_; |
| 174 | 173 |
| 175 DISALLOW_COPY_AND_ASSIGN(AutocompleteSyncableService); | 174 DISALLOW_COPY_AND_ASSIGN(AutocompleteSyncableService); |
| 176 }; | 175 }; |
| 177 | 176 |
| 178 #endif // CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ | 177 #endif // CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ |
| OLD | NEW |