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

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

Issue 2451843002: Add Store+Sync to reading list. (Closed)
Patch Set: reading_list_model_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.h
diff --git a/ios/chrome/browser/reading_list/reading_list_model.h b/ios/chrome/browser/reading_list/reading_list_model.h
index 625b19f5f2b503e458bb5f8b9603978f31ea8c02..88b28c8249239a0fa8727be48a561dfe400729c9 100644
--- a/ios/chrome/browser/reading_list/reading_list_model.h
+++ b/ios/chrome/browser/reading_list/reading_list_model.h
@@ -16,16 +16,21 @@
class GURL;
class ReadingListModel;
+class ReadingListStore;
namespace ios {
class ChromeBrowserState;
}
+namespace syncer {
+class ModelTypeService;
+}
+
// 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 {
public:
class ScopedReadingListBatchUpdate;
// Returns true if the model finished loading. Until this returns true the
@@ -35,6 +40,9 @@ class ReadingListModel {
// Returns true if the model is performing batch updates right now.
bool IsPerformingBatchUpdates() const;
+ // Returns the ModelTypeService responsible for handling sync message.
+ virtual syncer::ModelTypeService* GetModelTypeService() = 0;
+
// Tells model to prepare for batch updates.
// This method is reentrant, i.e. several batch updates may take place at the
// same time.
@@ -61,6 +69,11 @@ class ReadingListModel {
// Returns a specific entry. Returns null if the entry does not exist.
virtual const ReadingListEntry* GetEntryFromURL(const GURL& gurl) const = 0;
+ // Handle sync events.
+ virtual void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry,
+ bool read) = 0;
+ virtual void SyncRemoveEntry(const GURL& gurl) = 0;
+
// Synchronously calls the |callback| with entry associated with this |url|.
// Does nothing if there is no entry associated.
// Returns whether the callback has been called.
@@ -68,6 +81,15 @@ class ReadingListModel {
const GURL& url,
base::Callback<void(const ReadingListEntry&)> callback) const = 0;
+ // Synchronously calls the |callback| with entry associated with this |url|
+ // and its |read| status.
+ // Does nothing if there is no entry associated.
+ // Returns whether the callback has been called.
+ virtual bool CallbackEntryReadStatusURL(
+ const GURL& url,
+ base::Callback<void(const ReadingListEntry&, bool read)> callback)
+ const = 0;
+
// Adds |url| at the top of the unread entries, and removes entries with the
// same |url| from everywhere else if they exist. The addition may be
// asynchronous, and the data will be available only once the observers are
@@ -77,7 +99,7 @@ class ReadingListModel {
// Removes an entry. The removal may be asynchronous, and not happen
// immediately.
- virtual void RemoveEntryByUrl(const GURL& url) = 0;
+ virtual void RemoveEntryByURL(const GURL& url) = 0;
// If the |url| is in the reading list and unread, mark it read. If it is in
// the reading list and read, move it to the top of unread if it is not here
@@ -127,6 +149,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