| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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_DRIVER_CHANGE_PROCESSOR_H_ | |
| 6 #define COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "components/sync/core/base_transaction.h" | |
| 12 #include "components/sync/core/change_record.h" | |
| 13 #include "components/sync/core/user_share.h" | |
| 14 | |
| 15 namespace syncer { | |
| 16 class DataTypeErrorHandler; | |
| 17 class UnrecoverableErrorHandler; | |
| 18 } // namespace syncer | |
| 19 | |
| 20 namespace sync_driver { | |
| 21 | |
| 22 class ModelAssociator; | |
| 23 | |
| 24 // An interface used to apply changes from the sync model to the browser's | |
| 25 // native model. This does not currently distinguish between model data types. | |
| 26 class ChangeProcessor { | |
| 27 public: | |
| 28 explicit ChangeProcessor(syncer::DataTypeErrorHandler* error_handler); | |
| 29 virtual ~ChangeProcessor(); | |
| 30 | |
| 31 // Call when the processor should accept changes from either provided model | |
| 32 // and apply them to the other. Both the native model and sync_api are | |
| 33 // expected to be initialized and loaded. You must have set a valid | |
| 34 // ModelAssociator and UnrecoverableErrorHandler before using this method, and | |
| 35 // the two models should be associated w.r.t the ModelAssociator provided. | |
| 36 void Start(syncer::UserShare* share_handle); | |
| 37 | |
| 38 // Changes have been applied to the backend model and are ready to be | |
| 39 // applied to the frontend model. | |
| 40 virtual void ApplyChangesFromSyncModel( | |
| 41 const syncer::BaseTransaction* trans, | |
| 42 int64_t model_version, | |
| 43 const syncer::ImmutableChangeRecordList& changes) = 0; | |
| 44 | |
| 45 // The changes found in ApplyChangesFromSyncModel may be too slow to be | |
| 46 // performed while holding a [Read/Write]Transaction lock or may interact | |
| 47 // with another thread, which might itself be waiting on the transaction lock, | |
| 48 // putting us at risk of deadlock. | |
| 49 // This function is called once the transactional lock is released and it is | |
| 50 // safe to perform inter-thread or slow I/O operations. Note that not all | |
| 51 // datatypes need this, so we provide an empty default version. | |
| 52 virtual void CommitChangesFromSyncModel(); | |
| 53 | |
| 54 protected: | |
| 55 // These methods are invoked by Start() and Stop() to do | |
| 56 // implementation-specific work. | |
| 57 virtual void StartImpl() = 0; | |
| 58 | |
| 59 syncer::DataTypeErrorHandler* error_handler() const; | |
| 60 virtual syncer::UserShare* share_handle() const; | |
| 61 | |
| 62 private: | |
| 63 syncer::DataTypeErrorHandler* error_handler_; // Guaranteed to outlive us. | |
| 64 | |
| 65 // The sync model we are processing changes from. | |
| 66 syncer::UserShare* share_handle_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ChangeProcessor); | |
| 69 }; | |
| 70 | |
| 71 } // namespace sync_driver | |
| 72 | |
| 73 #endif // COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ | |
| OLD | NEW |