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 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_SYNC_MODEL_SYNC_CHANGE_PROCESSOR_H_ 6 #define COMPONENTS_SYNC_MODEL_SYNC_CHANGE_PROCESSOR_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "components/sync/base/model_type.h" 12 #include "components/sync/model/model_error.h" 13 #include "components/sync/model/sync_change.h" 14 #include "components/sync/model/sync_data.h" 15 #include "components/sync/model/sync_error.h" 16 17 namespace base { 18 class Location; 19 } // namespace base 20 21 namespace syncer { 22 23 // An interface for services that handle receiving SyncChanges. 24 class SyncChangeProcessor { 25 public: 26 SyncChangeProcessor() = default; 27 virtual ~SyncChangeProcessor() = default; 28 29 // Process a list of SyncChanges. 30 // Returns: base::nullopt if no error was encountered, otherwise a 31 // base::Optional filled with such error. 32 // Inputs: 33 // |from_here|: allows tracking of where sync changes originate. 34 // |change_list|: is the list of sync changes in need of processing. 35 virtual base::Optional<ModelError> ProcessSyncChanges( 36 const base::Location& from_here, 37 const SyncChangeList& change_list) = 0; 38 39 // Fills a list of SyncData. This should create an up to date representation 40 // of all the data known to the ChangeProcessor for |datatype|, and 41 // should match/be a subset of the server's view of that datatype. 42 // 43 // WARNING: This can be a potentially slow & memory intensive operation and 44 // should only be used when absolutely necessary / sparingly. 45 virtual SyncDataList GetAllSyncData(ModelType type) const = 0; 46 }; 47 48 } // namespace syncer 49 50 #endif // COMPONENTS_SYNC_MODEL_SYNC_CHANGE_PROCESSOR_H_ 51