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 0ae3b3c48161bb6c4c36467e9c4186913c2b2035..27345fc399b9d7a9358cfddc9b72603927c9917b 100644 |
--- a/ios/chrome/browser/reading_list/reading_list_model_impl.h |
+++ b/ios/chrome/browser/reading_list/reading_list_model_impl.h |
@@ -7,23 +7,30 @@ |
#include <memory> |
+#include "base/threading/non_thread_safe.h" |
#include "components/keyed_service/core/keyed_service.h" |
#include "ios/chrome/browser/reading_list/reading_list_entry.h" |
#include "ios/chrome/browser/reading_list/reading_list_model.h" |
class ReadingListModelStorage; |
+class PrefService; |
+ |
+using ReadingListEntries = std::vector<ReadingListEntry>; |
// Concrete implementation of a reading list model using in memory lists. |
class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
public: |
// Initialize a ReadingListModelImpl to load and save data in |
// |persistence_layer|. |
- ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer); |
+ ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer, |
+ PrefService* pref_service); |
// Initialize a ReadingListModelImpl without persistence. Data will not be |
// persistent across sessions. |
ReadingListModelImpl(); |
+ syncer::ModelTypeService* GetModelTypeService() override; |
+ |
~ReadingListModelImpl() override; |
// KeyedService implementation. |
@@ -32,6 +39,9 @@ class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
// ReadingListModel implementation. |
bool loaded() const override; |
+ virtual void ModelLoaded(std::unique_ptr<ReadingListEntries> unread, |
+ std::unique_ptr<ReadingListEntries> read); |
+ |
size_t unread_size() const override; |
size_t read_size() const override; |
@@ -47,7 +57,12 @@ class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
const GURL& url, |
base::Callback<void(const ReadingListEntry&)> callback) const override; |
- void RemoveEntryByUrl(const GURL& url) override; |
+ bool CallbackEntryReadStatusURL( |
+ const GURL& url, |
+ base::Callback<void(const ReadingListEntry&, bool read)> callback) |
+ const override; |
+ |
+ void RemoveEntryByURL(const GURL& url) override; |
const ReadingListEntry& AddEntry(const GURL& url, |
const std::string& title) override; |
@@ -62,18 +77,28 @@ class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
const GURL& url, |
ReadingListEntry::DistillationState state) override; |
+ void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry, |
+ bool read) override; |
+ void SyncRemoveEntry(const GURL& gurl) override; |
+ |
protected: |
- void EndBatchUpdates() override; |
+ void EnteringBatchUpdates() override; |
+ void LeavingBatchUpdates() override; |
private: |
- typedef std::vector<ReadingListEntry> ReadingListEntries; |
- |
- ReadingListEntries unread_; |
- ReadingListEntries read_; |
- std::unique_ptr<ReadingListModelStorage> storageLayer_; |
- bool hasUnseen_; |
+ void RemoveEntryByURLImpl(const GURL& url, bool from_sync); |
+ void SavePersistentHasUnseen(bool has_unseen); |
+ bool LoadPersistentHasUnseen(); |
+ ReadingListEntry* GetMutableEntryFromURL(const GURL& gurl, bool* read) const; |
+ void SortEntries(); |
+ |
+ std::unique_ptr<ReadingListEntries> unread_; |
+ std::unique_ptr<ReadingListEntries> read_; |
+ std::unique_ptr<ReadingListModelStorage> storage_layer_; |
+ PrefService* pref_service_; |
+ bool has_unseen_; |
bool loaded_; |
- |
+ base::WeakPtrFactory<ReadingListModelImpl> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl); |
}; |