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 | 15 |
16 class SyncData; | 16 class SyncData; |
| 17 class SyncError; |
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. |
| 29 // Returns: false if an error occurred (and |error| will be reset to describe |
| 30 // the error). |
| 31 // true otherwise. |
28 virtual bool MergeDataAndStartSyncing( | 32 virtual bool 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, |
| 36 SyncError* error) = 0; |
32 | 37 |
33 // Stop syncing the specified type and reset state. | 38 // Stop syncing the specified type and reset state. |
34 virtual void StopSyncing(syncable::ModelType type) = 0; | 39 virtual void StopSyncing(syncable::ModelType type) = 0; |
35 | 40 |
36 // Fills a list of SyncData from the local data. This should create an up | 41 // 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 | 42 // 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. | 43 // should match/be a subset of the server's view of that datatype. |
39 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const = 0; | 44 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const = 0; |
40 | 45 |
41 // SyncChangeProcessor interface. | 46 // SyncChangeProcessor interface. |
42 // Process a list of new SyncChanges and update the local data as necessary. | 47 // Process a list of new SyncChanges and update the local data as necessary. |
43 virtual void ProcessSyncChanges( | 48 // Returns: false if an error occurred (and |error| will be reset to describe |
| 49 // the error). |
| 50 // true otherwise. |
| 51 virtual bool ProcessSyncChanges( |
44 const tracked_objects::Location& from_here, | 52 const tracked_objects::Location& from_here, |
45 const SyncChangeList& change_list) OVERRIDE = 0; | 53 const SyncChangeList& change_list, |
| 54 SyncError* error) OVERRIDE = 0; |
46 | 55 |
47 protected: | 56 protected: |
48 virtual ~SyncableService(); | 57 virtual ~SyncableService(); |
49 }; | 58 }; |
50 | 59 |
51 #endif // CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ | 60 #endif // CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
OLD | NEW |