| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ | 5 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ | 
| 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ | 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ | 
| 7 | 7 | 
| 8 #include "base/threading/non_thread_safe.h" | 8 #include "base/threading/non_thread_safe.h" | 
| 9 #include "components/reading_list/ios/reading_list_model_storage.h" | 9 #include "components/reading_list/ios/reading_list_model_storage.h" | 
| 10 #include "components/reading_list/ios/reading_list_store_delegate.h" | 10 #include "components/reading_list/ios/reading_list_store_delegate.h" | 
| 11 #include "components/sync/model/model_type_store.h" | 11 #include "components/sync/model/model_type_store.h" | 
| 12 #include "components/sync/model/model_type_sync_bridge.h" |  | 
| 13 | 12 | 
| 14 namespace syncer { | 13 namespace syncer { | 
| 15 class MutableDataBatch; | 14 class MutableDataBatch; | 
| 16 } | 15 } | 
| 17 | 16 | 
| 18 class ReadingListModel; | 17 class ReadingListModel; | 
| 19 | 18 | 
| 20 // A ReadingListModelStorage storing and syncing data in protobufs. | 19 // A ReadingListModelStorage storing and syncing data in protobufs. | 
| 21 class ReadingListStore : public syncer::ModelTypeSyncBridge, | 20 class ReadingListStore : public ReadingListModelStorage, | 
| 22                          public ReadingListModelStorage, |  | 
| 23                          public base::NonThreadSafe { | 21                          public base::NonThreadSafe { | 
| 24   using StoreFactoryFunction = base::Callback<void( | 22   using StoreFactoryFunction = base::Callback<void( | 
| 25       const syncer::ModelTypeStore::InitCallback& callback)>; | 23       const syncer::ModelTypeStore::InitCallback& callback)>; | 
| 26 | 24 | 
| 27  public: | 25  public: | 
| 28   ReadingListStore(StoreFactoryFunction create_store_callback, | 26   ReadingListStore(StoreFactoryFunction create_store_callback, | 
| 29                    const ChangeProcessorFactory& change_processor_factory); | 27                    const ChangeProcessorFactory& change_processor_factory); | 
| 30   ~ReadingListStore() override; | 28   ~ReadingListStore() override; | 
| 31 | 29 | 
| 32   std::unique_ptr<ScopedBatchUpdate> EnsureBatchCreated() override; | 30   std::unique_ptr<ScopedBatchUpdate> EnsureBatchCreated() override; | 
| 33 | 31 | 
| 34   // ReadingListModelStorage implementation | 32   // ReadingListModelStorage implementation | 
| 35   void SetReadingListModel(ReadingListModel* model, | 33   void SetReadingListModel(ReadingListModel* model, | 
| 36                            ReadingListStoreDelegate* delegate) override; | 34                            ReadingListStoreDelegate* delegate) override; | 
| 37 | 35 | 
| 38   void SaveEntry(const ReadingListEntry& entry) override; | 36   void SaveEntry(const ReadingListEntry& entry) override; | 
| 39   void RemoveEntry(const ReadingListEntry& entry) override; | 37   void RemoveEntry(const ReadingListEntry& entry) override; | 
| 40 | 38 | 
| 41   // ReadingListModelStorage implementation. |  | 
| 42   syncer::ModelTypeSyncBridge* GetModelTypeSyncBridge() override; |  | 
| 43 |  | 
| 44   // Creates an object used to communicate changes in the sync metadata to the | 39   // Creates an object used to communicate changes in the sync metadata to the | 
| 45   // model type store. | 40   // model type store. | 
| 46   std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() | 41   std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() | 
| 47       override; | 42       override; | 
| 48 | 43 | 
| 49   // Perform the initial merge between local and sync data. This should only be | 44   // Perform the initial merge between local and sync data. This should only be | 
| 50   // called when a data type is first enabled to start syncing, and there is no | 45   // called when a data type is first enabled to start syncing, and there is no | 
| 51   // sync metadata. Best effort should be made to match local and sync data. The | 46   // sync metadata. Best effort should be made to match local and sync data. The | 
| 52   // keys in the |entity_data_map| will have been created via GetClientTag(...), | 47   // keys in the |entity_data_map| will have been created via GetClientTag(...), | 
| 53   // and if a local and sync data should match/merge but disagree on tags, the | 48   // and if a local and sync data should match/merge but disagree on tags, the | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 155   std::unique_ptr<syncer::ModelTypeStore> store_; | 150   std::unique_ptr<syncer::ModelTypeStore> store_; | 
| 156   ReadingListModel* model_; | 151   ReadingListModel* model_; | 
| 157   ReadingListStoreDelegate* delegate_; | 152   ReadingListStoreDelegate* delegate_; | 
| 158   StoreFactoryFunction create_store_callback_; | 153   StoreFactoryFunction create_store_callback_; | 
| 159 | 154 | 
| 160   int pending_transaction_count_; | 155   int pending_transaction_count_; | 
| 161   std::unique_ptr<syncer::ModelTypeStore::WriteBatch> batch_; | 156   std::unique_ptr<syncer::ModelTypeStore::WriteBatch> batch_; | 
| 162 }; | 157 }; | 
| 163 | 158 | 
| 164 #endif  // COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ | 159 #endif  // COMPONENTS_READING_LIST_IOS_READING_LIST_STORE_H_ | 
| OLD | NEW | 
|---|