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..a4d13112759c481813c25fd11644569702e076a2 100644 |
--- a/ios/chrome/browser/reading_list/reading_list_model_impl.h |
+++ b/ios/chrome/browser/reading_list/reading_list_model_impl.h |
@@ -12,18 +12,24 @@ |
#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. |
@@ -47,6 +53,11 @@ class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
const GURL& url, |
base::Callback<void(const ReadingListEntry&)> callback) const 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, |
@@ -62,18 +73,31 @@ class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
const GURL& url, |
ReadingListEntry::DistillationState state) override; |
+ virtual void ModelLoaded(std::unique_ptr<ReadingListEntries> unread, |
+ std::unique_ptr<ReadingListEntries> read); |
+ |
+ 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); |
}; |