Chromium Code Reviews| Index: ios/chrome/browser/reading_list/reading_list_model_impl.h |
| diff --git a/ios/chrome/browser/reading_list/reading_list_model_impl.h b/ios/chrome/browser/reading_list/reading_list_model_impl.h |
| index e755f34df44b1769c5c52baa49066433ae8737a6..3d97093a3e2f20f1640e89aa8e0638e32a0293ee 100644 |
| --- a/ios/chrome/browser/reading_list/reading_list_model_impl.h |
| +++ b/ios/chrome/browser/reading_list/reading_list_model_impl.h |
| @@ -6,6 +6,7 @@ |
| #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_IMPL_H_ |
| #include <memory> |
| +#include <unordered_map> |
| #include "components/keyed_service/core/keyed_service.h" |
| #include "ios/chrome/browser/reading_list/reading_list_entry.h" |
| @@ -33,8 +34,7 @@ class ReadingListModelImpl : public ReadingListModel, |
| ~ReadingListModelImpl() override; |
| - void StoreLoaded(std::unique_ptr<ReadingListEntries> unread, |
| - std::unique_ptr<ReadingListEntries> read) override; |
| + void StoreLoaded(std::unique_ptr<ReadingListEntries> entries) override; |
| // KeyedService implementation. |
| void Shutdown() override; |
| @@ -42,17 +42,17 @@ class ReadingListModelImpl : public ReadingListModel, |
| // ReadingListModel implementation. |
| bool loaded() const override; |
| + size_t size() const override; |
| size_t unread_size() const override; |
|
gambard
2016/11/23 12:11:07
Will this be deleted?
Olivier
2016/11/28 14:54:15
Done.
|
| size_t read_size() const override; |
| bool HasUnseenEntries() const override; |
| void ResetUnseenEntries() override; |
| - const ReadingListEntry& GetUnreadEntryAtIndex(size_t index) const override; |
| - const ReadingListEntry& GetReadEntryAtIndex(size_t index) const override; |
| - |
| - const ReadingListEntry* GetEntryFromURL(const GURL& gurl, |
| - bool* read) const override; |
| + const ReadingListEntry* GetEntryFromURL(const GURL& gurl) const override; |
| + const ReadingListEntry* GetEntryAt(size_t index) const override; |
| + const ReadingListEntry* GetReadEntryAt(size_t index) const override; |
| + const ReadingListEntry* GetUnreadEntryAt(size_t index) const override; |
| bool CallbackEntryURL( |
| const GURL& url, |
| @@ -63,8 +63,7 @@ class ReadingListModelImpl : public ReadingListModel, |
| const ReadingListEntry& AddEntry(const GURL& url, |
| const std::string& title) override; |
| - void MarkReadByURL(const GURL& url) override; |
| - void MarkUnreadByURL(const GURL& url) override; |
| + void SetReadStatus(const GURL& url, bool read) override; |
| void SetEntryTitle(const GURL& url, const std::string& title) override; |
| void SetEntryDistilledPath(const GURL& url, |
| @@ -73,10 +72,9 @@ class ReadingListModelImpl : public ReadingListModel, |
| const GURL& url, |
| ReadingListEntry::DistillationState state) override; |
| - void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry, |
| - bool read) override; |
| - ReadingListEntry* SyncMergeEntry(std::unique_ptr<ReadingListEntry> entry, |
| - bool read) override; |
| + void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry) override; |
| + ReadingListEntry* SyncMergeEntry( |
| + std::unique_ptr<ReadingListEntry> entry) override; |
| void SyncRemoveEntry(const GURL& url) override; |
| std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> |
| @@ -109,10 +107,7 @@ class ReadingListModelImpl : public ReadingListModel, |
| // Returns a mutable pointer to the entry with URL |gurl|. Return nullptr if |
| // no entry is found. If an entry is found, |read| is set to the read status |
|
jif-google
2016/11/22 18:21:45
update comment.
Olivier
2016/11/28 14:54:14
Done.
|
| // of the entry. |
| - ReadingListEntry* GetMutableEntryFromURL(const GURL& gurl, bool* read) const; |
| - |
| - // Sorts the entries in |read_| and |unread_| according to their |UpdateTime|. |
| - void SortEntries(); |
| + ReadingListEntry* GetMutableEntryFromURL(const GURL& gurl) const; |
| // Returns the |storage_layer_| of the model. |
| ReadingListModelStorage* StorageLayer(); |
| @@ -126,8 +121,21 @@ class ReadingListModelImpl : public ReadingListModel, |
| // Remove entry |url| and propagate to store if |from_sync| is false. |
| void RemoveEntryByURLImpl(const GURL& url, bool from_sync); |
| - std::unique_ptr<ReadingListEntries> unread_; |
| - std::unique_ptr<ReadingListEntries> read_; |
| + void RebuildIndex() const; |
| + |
| + std::unique_ptr<ReadingListEntries> entries_; |
| + size_t unread_entry_count_; |
| + size_t read_entry_count_; |
| + |
| + struct Cache { |
| + Cache(); |
| + ~Cache(); |
| + std::vector<GURL> read_entries; |
| + std::vector<GURL> unread_entries; |
| + bool dirty; |
| + }; |
| + std::unique_ptr<struct Cache> cache_; |
| + |
| std::unique_ptr<ReadingListModelStorage> storage_layer_; |
| PrefService* pref_service_; |
| bool has_unseen_; |