Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: ios/chrome/browser/reading_list/reading_list_model_impl.h

Issue 2451843002: Add Store+Sync to reading list. (Closed)
Patch Set: jif' feedback + reading_list_store_unittests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..613a43fca912c29da6e8345d7561ae209ef9b0b0 100644
--- a/ios/chrome/browser/reading_list/reading_list_model_impl.h
+++ b/ios/chrome/browser/reading_list/reading_list_model_impl.h
@@ -7,25 +7,38 @@
#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"
+#include "ios/chrome/browser/reading_list/reading_list_store_delegate.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 {
+class ReadingListModelImpl : public ReadingListModel,
+ public ReadingListStoreDelegate,
+ 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;
+ void StoreLoaded(std::unique_ptr<ReadingListEntries> unread,
+ std::unique_ptr<ReadingListEntries> read) override;
+
// KeyedService implementation.
void Shutdown() override;
@@ -47,7 +60,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 +80,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 SetPersistentHasUnseen(bool has_unseen);
+ bool GetPersistentHasUnseen();
+ 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);
};

Powered by Google App Engine
This is Rietveld 408576698