| 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_MODEL_STORAGE_H_ | 5 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_ |
| 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_ | 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/reading_list/ios/reading_list_entry.h" | 11 #include "components/reading_list/ios/reading_list_entry.h" |
| 12 #include "components/sync/base/model_type.h" | 12 #include "components/sync/base/model_type.h" |
| 13 #include "components/sync/model/model_type_sync_bridge.h" | 13 #include "components/sync/model/model_type_sync_bridge.h" |
| 14 | 14 |
| 15 class ReadingListModel; | 15 class ReadingListModel; |
| 16 class ReadingListStoreDelegate; | 16 class ReadingListStoreDelegate; |
| 17 | 17 |
| 18 namespace base { |
| 19 class Clock; |
| 20 } |
| 21 |
| 18 namespace syncer { | 22 namespace syncer { |
| 19 class ModelTypeSyncBridge; | 23 class ModelTypeSyncBridge; |
| 20 } | 24 } |
| 21 | 25 |
| 22 // Interface for a persistence layer for reading list. | 26 // Interface for a persistence layer for reading list. |
| 23 // All interface methods have to be called on main thread. | 27 // All interface methods have to be called on main thread. |
| 24 class ReadingListModelStorage : public syncer::ModelTypeSyncBridge { | 28 class ReadingListModelStorage : public syncer::ModelTypeSyncBridge { |
| 25 public: | 29 public: |
| 26 class ScopedBatchUpdate; | 30 class ScopedBatchUpdate; |
| 27 | 31 |
| 28 ReadingListModelStorage( | 32 ReadingListModelStorage( |
| 29 const ChangeProcessorFactory& change_processor_factory, | 33 const ChangeProcessorFactory& change_processor_factory, |
| 30 syncer::ModelType type); | 34 syncer::ModelType type); |
| 31 ~ReadingListModelStorage() override; | 35 ~ReadingListModelStorage() override; |
| 32 | 36 |
| 33 // Sets the model the Storage is backing. | 37 // Sets the model the Storage is backing. |
| 34 // This will trigger store initalization and load persistent entries. | 38 // This will trigger store initalization and load persistent entries. |
| 39 // Pass the |clock| from the |model| to ensure synchroization when loading |
| 40 // entries. |
| 35 virtual void SetReadingListModel(ReadingListModel* model, | 41 virtual void SetReadingListModel(ReadingListModel* model, |
| 36 ReadingListStoreDelegate* delegate) = 0; | 42 ReadingListStoreDelegate* delegate, |
| 43 base::Clock* clock) = 0; |
| 37 | 44 |
| 38 // Starts a transaction. All Save/Remove entry will be delayed until the | 45 // Starts a transaction. All Save/Remove entry will be delayed until the |
| 39 // transaction is commited. | 46 // transaction is commited. |
| 40 // Multiple transaction can be started at the same time. Commit will happen | 47 // Multiple transaction can be started at the same time. Commit will happen |
| 41 // when the last transaction is commited. | 48 // when the last transaction is commited. |
| 42 // Returns a scoped batch update object that should be retained while the | 49 // Returns a scoped batch update object that should be retained while the |
| 43 // batch update is performed. Deallocating this object will inform model that | 50 // batch update is performed. Deallocating this object will inform model that |
| 44 // the batch update has completed. | 51 // the batch update has completed. |
| 45 virtual std::unique_ptr<ScopedBatchUpdate> EnsureBatchCreated() = 0; | 52 virtual std::unique_ptr<ScopedBatchUpdate> EnsureBatchCreated() = 0; |
| 46 | 53 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 | 65 |
| 59 private: | 66 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(ScopedBatchUpdate); | 67 DISALLOW_COPY_AND_ASSIGN(ScopedBatchUpdate); |
| 61 }; | 68 }; |
| 62 | 69 |
| 63 private: | 70 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(ReadingListModelStorage); | 71 DISALLOW_COPY_AND_ASSIGN(ReadingListModelStorage); |
| 65 }; | 72 }; |
| 66 | 73 |
| 67 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_ | 74 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_ |
| OLD | NEW |