| 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 f84f8616caa925df1603ab437f7a3c87b8995787..4847ef978559def73939f1b5b8e6bbe8f504a821 100644
|
| --- a/ios/chrome/browser/reading_list/reading_list_model.h
|
| +++ b/ios/chrome/browser/reading_list/reading_list_model.h
|
| @@ -11,23 +11,32 @@
|
|
|
| #include "base/callback.h"
|
| #include "base/observer_list.h"
|
| +#include "base/threading/non_thread_safe.h"
|
| #include "ios/chrome/browser/reading_list/reading_list_entry.h"
|
| #include "ios/chrome/browser/reading_list/reading_list_model_observer.h"
|
|
|
| class GURL;
|
| +class ReadingListEntry;
|
| class ReadingListModel;
|
| +class ReadingListStore;
|
| +class ScopedReadingListBatchUpdate;
|
|
|
| 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 {
|
| 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 +44,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 +55,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 +74,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.
|
| @@ -109,7 +127,7 @@ class ReadingListModel {
|
| explicit ScopedReadingListBatchUpdate(ReadingListModel* model)
|
| : model_(model) {}
|
|
|
| - ~ScopedReadingListBatchUpdate() { model_->EndBatchUpdates(); }
|
| + virtual ~ScopedReadingListBatchUpdate();
|
|
|
| private:
|
| ReadingListModel* model_;
|
| @@ -128,6 +146,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_;
|
|
|
|
|