OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_READING_LIST_READING_LIST_MODEL_STORAGE_H_ | |
6 #define COMPONENTS_READING_LIST_READING_LIST_MODEL_STORAGE_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "components/reading_list/reading_list_entry.h" | |
11 | |
12 class ReadingListModel; | |
13 class ReadingListStoreDelegate; | |
14 | |
15 namespace syncer { | |
16 class ModelTypeSyncBridge; | |
17 } | |
18 | |
19 // Interface for a persistence layer for reading list. | |
20 // All interface methods have to be called on main thread. | |
21 class ReadingListModelStorage { | |
22 public: | |
23 class ScopedBatchUpdate; | |
24 | |
25 // Sets the model the Storage is backing. | |
26 // This will trigger store initalization and load persistent entries. | |
27 virtual void SetReadingListModel(ReadingListModel* model, | |
28 ReadingListStoreDelegate* delegate) = 0; | |
29 | |
30 // Returns the class responsible for handling sync messages. | |
31 virtual syncer::ModelTypeSyncBridge* GetModelTypeSyncBridge() = 0; | |
32 | |
33 // Starts a transaction. All Save/Remove entry will be delayed until the | |
34 // transaction is commited. | |
35 // Multiple transaction can be started at the same time. Commit will happen | |
36 // when the last transaction is commited. | |
37 // Returns a scoped batch update object that should be retained while the | |
38 // batch update is performed. Deallocating this object will inform model that | |
39 // the batch update has completed. | |
40 virtual std::unique_ptr<ScopedBatchUpdate> EnsureBatchCreated() = 0; | |
41 | |
42 // Saves or updates an entry. If the entry is not yet in the database, it is | |
43 // created. | |
44 virtual void SaveEntry(const ReadingListEntry& entry, bool read) = 0; | |
45 | |
46 // Removed an entry from the storage. | |
47 virtual void RemoveEntry(const ReadingListEntry& entry) = 0; | |
48 | |
49 class ScopedBatchUpdate { | |
50 public: | |
51 virtual ~ScopedBatchUpdate() {} | |
52 }; | |
53 }; | |
54 | |
55 #endif // COMPONENTS_READING_LIST_READING_LIST_MODEL_STORAGE_H_ | |
OLD | NEW |