| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/sync/syncable/model_type.h" | 12 #include "chrome/browser/sync/syncable/model_type.h" |
| 13 #include "chrome/browser/sync/api/sync_change_processor.h" | 13 #include "chrome/browser/sync/api/sync_change_processor.h" |
| 14 #include "chrome/browser/sync/api/sync_data.h" | 14 #include "chrome/browser/sync/api/sync_data.h" |
| 15 #include "chrome/browser/sync/api/sync_error.h" |
| 15 | 16 |
| 16 class SyncData; | 17 class SyncData; |
| 17 | 18 |
| 18 typedef std::vector<SyncData> SyncDataList; | 19 typedef std::vector<SyncData> SyncDataList; |
| 19 | 20 |
| 20 class SyncableService : public SyncChangeProcessor { | 21 class SyncableService : public SyncChangeProcessor { |
| 21 public: | 22 public: |
| 22 // Informs the service to begin syncing the specified synced datatype |type|. | 23 // Informs the service to begin syncing the specified synced datatype |type|. |
| 23 // The service should then merge |initial_sync_data| into it's local data, | 24 // The service should then merge |initial_sync_data| into it's local data, |
| 24 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the | 25 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the |
| 25 // two. After this, the SyncableService's local data should match the server | 26 // two. After this, the SyncableService's local data should match the server |
| 26 // data, and the service should be ready to receive and process any further | 27 // data, and the service should be ready to receive and process any further |
| 27 // SyncChange's as they occur. | 28 // SyncChange's as they occur. |
| 28 virtual bool MergeDataAndStartSyncing( | 29 // Returns: A default SyncError (IsSet() == false) if no errors were |
| 30 // encountered, and a filled SyncError (IsSet() == true) |
| 31 // otherwise. |
| 32 virtual SyncError MergeDataAndStartSyncing( |
| 29 syncable::ModelType type, | 33 syncable::ModelType type, |
| 30 const SyncDataList& initial_sync_data, | 34 const SyncDataList& initial_sync_data, |
| 31 SyncChangeProcessor* sync_processor) = 0; | 35 SyncChangeProcessor* sync_processor) = 0; |
| 32 | 36 |
| 33 // Stop syncing the specified type and reset state. | 37 // Stop syncing the specified type and reset state. |
| 34 virtual void StopSyncing(syncable::ModelType type) = 0; | 38 virtual void StopSyncing(syncable::ModelType type) = 0; |
| 35 | 39 |
| 36 // Fills a list of SyncData from the local data. This should create an up | 40 // Fills a list of SyncData from the local data. This should create an up |
| 37 // to date representation of the SyncableService's view of that datatype, and | 41 // to date representation of the SyncableService's view of that datatype, and |
| 38 // should match/be a subset of the server's view of that datatype. | 42 // should match/be a subset of the server's view of that datatype. |
| 39 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const = 0; | 43 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const = 0; |
| 40 | 44 |
| 41 // SyncChangeProcessor interface. | 45 // SyncChangeProcessor interface. |
| 42 // Process a list of new SyncChanges and update the local data as necessary. | 46 // Process a list of new SyncChanges and update the local data as necessary. |
| 43 virtual void ProcessSyncChanges( | 47 // Returns: A default SyncError (IsSet() == false) if no errors were |
| 48 // encountered, and a filled SyncError (IsSet() == true) |
| 49 // otherwise. |
| 50 virtual SyncError ProcessSyncChanges( |
| 44 const tracked_objects::Location& from_here, | 51 const tracked_objects::Location& from_here, |
| 45 const SyncChangeList& change_list) OVERRIDE = 0; | 52 const SyncChangeList& change_list) OVERRIDE = 0; |
| 46 | 53 |
| 47 protected: | 54 protected: |
| 48 virtual ~SyncableService(); | 55 virtual ~SyncableService(); |
| 49 }; | 56 }; |
| 50 | 57 |
| 51 #endif // CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ | 58 #endif // CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
| OLD | NEW |