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 IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_STORAGE_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_STORAGE_H_ |
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_STORAGE_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_STORAGE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ios/chrome/browser/reading_list/reading_list_entry.h" | 10 #include "ios/chrome/browser/reading_list/reading_list_entry.h" |
11 | 11 |
12 class ReadingListModel; | 12 class ReadingListModelImpl; |
| 13 |
| 14 namespace syncer { |
| 15 class SyncableService; |
| 16 } |
13 | 17 |
14 // Interface for a persistence layer for reading list. | 18 // Interface for a persistence layer for reading list. |
15 // All interface methods have to be called on main thread. | 19 // All interface methods have to be called on main thread. |
16 class ReadingListModelStorage { | 20 class ReadingListModelStorage { |
17 public: | 21 public: |
18 virtual std::vector<ReadingListEntry> LoadPersistentReadList() = 0; | 22 // Sets the model the Storage is backing. |
19 virtual std::vector<ReadingListEntry> LoadPersistentUnreadList() = 0; | 23 virtual void SetReadingListModel(ReadingListModelImpl* model) = 0; |
20 virtual bool LoadPersistentHasUnseen() = 0; | |
21 | 24 |
22 virtual void SavePersistentReadList( | 25 // Asynchronously Loads the entries contained in the storage. |
23 const std::vector<ReadingListEntry>& read) = 0; | 26 virtual void LoadPersistentLists() = 0; |
24 virtual void SavePersistentUnreadList( | 27 |
25 const std::vector<ReadingListEntry>& unread) = 0; | 28 // Starts a transation. All Save/Remove entry will be delayed until the |
26 virtual void SavePersistentHasUnseen(bool has_unseen) = 0; | 29 // transaction is commited. |
| 30 // Multiple transaction can be started at the same time. Commit will happen |
| 31 // when the last transaction is commited. |
| 32 // Calls to BeginTransaction and CommitTransaction must be balanced. |
| 33 virtual void BeginTransaction() = 0; |
| 34 virtual void CommitTransaction() = 0; |
| 35 |
| 36 // Saves or updates an entry. If the entry is not yet in the database, it is |
| 37 // created. |
| 38 virtual void SaveEntry(const ReadingListEntry& entry, bool read) = 0; |
| 39 |
| 40 // Removed an entry from the storage. |
| 41 virtual void RemoveEntry(const ReadingListEntry& entry) = 0; |
27 }; | 42 }; |
28 | 43 |
29 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_STORAGE_H_ | 44 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_STORAGE_H_ |
OLD | NEW |