Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 | 4 |
| 5 #ifndef SYNC_API_SYNC_CHANGE_PROCESSOR_H_ | 5 #ifndef SYNC_API_SYNC_CHANGE_PROCESSOR_H_ |
| 6 #define SYNC_API_SYNC_CHANGE_PROCESSOR_H_ | 6 #define SYNC_API_SYNC_CHANGE_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "sync/api/sync_data.h" | 10 #include "sync/api/sync_data.h" |
| 11 #include "sync/api/sync_error.h" | 11 #include "sync/api/sync_error.h" |
| 12 #include "sync/base/sync_export.h" | 12 #include "sync/base/sync_export.h" |
| 13 #include "sync/internal_api/public/base/model_type.h" | 13 #include "sync/internal_api/public/base/model_type.h" |
| 14 | 14 |
| 15 namespace tracked_objects { | 15 namespace tracked_objects { |
| 16 class Location; | 16 class Location; |
| 17 } // namespace tracked_objects | 17 } // namespace tracked_objects |
| 18 | 18 |
| 19 namespace syncer { | 19 namespace syncer { |
| 20 | 20 |
| 21 class SyncChange; | 21 class SyncChange; |
| 22 | 22 |
| 23 typedef std::vector<SyncChange> SyncChangeList; | 23 typedef std::vector<SyncChange> SyncChangeList; |
| 24 | 24 |
| 25 // An interface for services that handle receiving SyncChanges. | 25 // An interface for services that handle receiving SyncChanges. |
| 26 class SYNC_EXPORT SyncChangeProcessor { | 26 class SYNC_EXPORT SyncChangeProcessor { |
| 27 public: | 27 public: |
| 28 typedef base::Callback<void(const SyncData&)> GetSyncDataCallback; | |
| 29 | |
| 28 SyncChangeProcessor(); | 30 SyncChangeProcessor(); |
| 29 virtual ~SyncChangeProcessor(); | 31 virtual ~SyncChangeProcessor(); |
| 30 | 32 |
| 31 // Process a list of SyncChanges. | 33 // Process a list of SyncChanges. |
| 32 // Returns: A default SyncError (IsSet() == false) if no errors were | 34 // Returns: A default SyncError (IsSet() == false) if no errors were |
| 33 // encountered, and a filled SyncError (IsSet() == true) | 35 // encountered, and a filled SyncError (IsSet() == true) |
| 34 // otherwise. | 36 // otherwise. |
| 35 // Inputs: | 37 // Inputs: |
| 36 // |from_here|: allows tracking of where sync changes originate. | 38 // |from_here|: allows tracking of where sync changes originate. |
| 37 // |change_list|: is the list of sync changes in need of processing. | 39 // |change_list|: is the list of sync changes in need of processing. |
| 38 virtual SyncError ProcessSyncChanges( | 40 virtual SyncError ProcessSyncChanges( |
| 39 const tracked_objects::Location& from_here, | 41 const tracked_objects::Location& from_here, |
| 40 const SyncChangeList& change_list) = 0; | 42 const SyncChangeList& change_list) = 0; |
| 41 | 43 |
| 42 // Fills a list of SyncData. This should create an up to date representation | 44 // Fills a list of SyncData. This should create an up to date representation |
| 43 // of all the data known to the ChangeProcessor for |datatype|, and | 45 // of all the data known to the ChangeProcessor for |datatype|, and |
| 44 // should match/be a subset of the server's view of that datatype. | 46 // should match/be a subset of the server's view of that datatype. |
| 45 // | 47 // |
| 46 // WARNING: This can be a potentially slow & memory intensive operation and | 48 // WARNING: This can be a potentially slow & memory intensive operation and |
| 47 // should only be used when absolutely necessary / sparingly. | 49 // should only be used when absolutely necessary / sparingly. |
| 48 virtual SyncDataList GetAllSyncData(ModelType type) const = 0; | 50 virtual SyncDataList GetAllSyncData(ModelType type) const = 0; |
| 51 | |
| 52 // Retrieves the SyncData identified by |type| and |sync_tag| and invokes | |
| 53 // |callback|. If no such SyncData exists, IsValid on the SyncData passed to | |
|
tim (not reviewing)
2014/03/10 22:55:58
"... invokes |callback| asynchronously."
Also, wh
maniscalco
2014/03/18 20:49:18
Done.
| |
| 54 // |callback| will return false. | |
| 55 // | |
| 56 // This can be a potentially slow operation and may result in disk IO. | |
| 57 // | |
| 58 // TODO:(maniscalco): N.B. this method should really be pure virtual. An | |
| 59 // implentation is provide here just to verify that everything compiles. | |
|
tim (not reviewing)
2014/03/10 22:55:58
'implementation is provided'
maniscalco
2014/03/18 20:49:18
Done.
| |
| 60 // Update this method to be pure virtual before committing. | |
| 61 virtual void GetSyncData(const ModelType& type, | |
|
tim (not reviewing)
2014/03/10 22:55:58
I want to call this GetSyncDataAsync, but Sync/Asy
maniscalco
2014/03/18 20:49:18
Yes, it's local only. I've updated the comment in
| |
| 62 const std::string& sync_tag, | |
|
tim (not reviewing)
2014/03/10 22:55:58
Comment for sync_tag, refer to sync_data.h for det
maniscalco
2014/03/18 20:49:18
Done.
| |
| 63 const GetSyncDataCallback& callback) const {} | |
| 49 }; | 64 }; |
| 50 | 65 |
| 51 } // namespace syncer | 66 } // namespace syncer |
| 52 | 67 |
| 53 #endif // SYNC_API_SYNC_CHANGE_PROCESSOR_H_ | 68 #endif // SYNC_API_SYNC_CHANGE_PROCESSOR_H_ |
| OLD | NEW |