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

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

Issue 2451843002: Add Store+Sync to reading list. (Closed)
Patch Set: rebase 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.h
diff --git a/ios/chrome/browser/reading_list/reading_list_model.h b/ios/chrome/browser/reading_list/reading_list_model.h
index 417237ee14fb7e38650d725f781229ebc4b9b542..245512cccb8f3487e17e13a63263062c2beacb6f 100644
--- a/ios/chrome/browser/reading_list/reading_list_model.h
+++ b/ios/chrome/browser/reading_list/reading_list_model.h
@@ -15,19 +15,29 @@
#include "ios/chrome/browser/reading_list/reading_list_model_observer.h"
class GURL;
+class ReadingListEntry;
class ReadingListModel;
+class ReadingListStore;
+class ScopedReadingListBatchUpdate;
+
+using ReadingListEntries = std::vector<ReadingListEntry>;
pavely 2016/11/14 07:45:33 reading_list_model.h, reading_list_store_delegate.
Olivier 2016/11/14 11:36:48 Done.
namespace ios {
class ChromeBrowserState;
}
+namespace syncer {
+class ModelTypeSyncBridge;
+}
+
// The reading list model contains two list of entries: one of unread urls, the
// other of read ones. This object should only be accessed from one thread
// (Usually the main thread). The observers callbacks are also sent on the main
// thread.
-class ReadingListModel {
+class ReadingListModel : public base::NonThreadSafe {
pavely 2016/11/14 07:45:33 You need to include non_thread_safe.h.
Olivier 2016/11/14 11:36:48 Done.
public:
class ScopedReadingListBatchUpdate;
+
// Returns true if the model finished loading. Until this returns true the
// reading list is not ready for use.
virtual bool loaded() const = 0;
@@ -35,6 +45,9 @@ class ReadingListModel {
// Returns true if the model is performing batch updates right now.
bool IsPerformingBatchUpdates() const;
+ // Returns the ModelTypeSyncBridge responsible for handling sync message.
+ virtual syncer::ModelTypeSyncBridge* GetModelTypeSyncBridge() = 0;
+
// Tells model to prepare for batch updates.
// This method is reentrant, i.e. several batch updates may take place at the
// same time.
@@ -43,6 +56,9 @@ class ReadingListModel {
// the batch update has completed.
std::unique_ptr<ScopedReadingListBatchUpdate> BeginBatchUpdates();
+ // Creates a batch token that will freeze the model while in scope.
+ virtual std::unique_ptr<ScopedReadingListBatchUpdate> CreateBatchToken();
+
// Returns the size of read and unread entries.
virtual size_t unread_size() const = 0;
virtual size_t read_size() const = 0;
@@ -59,7 +75,10 @@ class ReadingListModel {
virtual const ReadingListEntry& GetReadEntryAtIndex(size_t index) const = 0;
// Returns a specific entry. Returns null if the entry does not exist.
- virtual const ReadingListEntry* GetEntryFromURL(const GURL& gurl) const = 0;
+ // If |read| is not null and the entry is found, |*read| is the read status
+ // of the entry.
+ virtual const ReadingListEntry* GetEntryFromURL(const GURL& gurl,
+ bool* read) const = 0;
// Synchronously calls the |callback| with entry associated with this |url|.
// Does nothing if there is no entry associated.
@@ -112,7 +131,7 @@ class ReadingListModel {
explicit ScopedReadingListBatchUpdate(ReadingListModel* model)
: model_(model) {}
- ~ScopedReadingListBatchUpdate() { model_->EndBatchUpdates(); }
+ virtual ~ScopedReadingListBatchUpdate();
private:
ReadingListModel* model_;
@@ -131,6 +150,12 @@ class ReadingListModel {
// ReadingListBatchUpdateToken dtor.
virtual void EndBatchUpdates();
+ // Called when model is entering batch update mode.
+ virtual void EnteringBatchUpdates();
+
+ // Called when model is leaving batch update mode.
+ virtual void LeavingBatchUpdates();
+
private:
unsigned int current_batch_updates_count_;

Powered by Google App Engine
This is Rietveld 408576698