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