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

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_model.h

Issue 2434993002: Add methods to Reading List Model (Closed)
Patch Set: Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const std::string& title) = 0; 72 const std::string& title) = 0;
73 73
74 // Removes an entry. The removal may be asynchronous, and not happen 74 // Removes an entry. The removal may be asynchronous, and not happen
75 // immediately. 75 // immediately.
76 virtual void RemoveEntryByUrl(const GURL& url) = 0; 76 virtual void RemoveEntryByUrl(const GURL& url) = 0;
77 77
78 // If the |url| is in the reading list and unread, mark it read. If it is in 78 // If the |url| is in the reading list and unread, mark it read. If it is in
79 // the reading list and read, move it to the top of unread if it is not here 79 // the reading list and read, move it to the top of unread if it is not here
80 // already. This may trigger deletion of old read entries. 80 // already. This may trigger deletion of old read entries.
81 virtual void MarkReadByURL(const GURL& url) = 0; 81 virtual void MarkReadByURL(const GURL& url) = 0;
82 // If the |url| is in the reading list and read, mark it unread. If it is in
83 // the reading list and unread, move it to the top of read if it is not here
84 // already.
85 virtual void MarkUnreadByURL(const GURL& url) = 0;
82 86
83 // Methods to mutate an entry. Will locate the relevant entry by URL. Does 87 // Methods to mutate an entry. Will locate the relevant entry by URL. Does
84 // nothing if the entry is not found. 88 // nothing if the entry is not found.
85 virtual void SetEntryTitle(const GURL& url, const std::string& title) = 0; 89 virtual void SetEntryTitle(const GURL& url, const std::string& title) = 0;
86 virtual void SetEntryDistilledURL(const GURL& url, 90 virtual void SetEntryDistilledURL(const GURL& url,
87 const GURL& distilled_url) = 0; 91 const GURL& distilled_url) = 0;
88 virtual void SetEntryDistilledState( 92 virtual void SetEntryDistilledState(
89 const GURL& url, 93 const GURL& url,
90 ReadingListEntry::DistillationState state) = 0; 94 ReadingListEntry::DistillationState state) = 0;
91 95
92 // Observer registration methods. The model will remove all observers upon 96 // Observer registration methods. The model will remove all observers upon
93 // destruction automatically. 97 // destruction automatically.
94 void AddObserver(ReadingListModelObserver* observer); 98 void AddObserver(ReadingListModelObserver* observer);
95 void RemoveObserver(ReadingListModelObserver* observer); 99 void RemoveObserver(ReadingListModelObserver* observer);
96 100
97 // Helper class that is used to scope batch updates. 101 // Helper class that is used to scope batch updates.
98 class ScopedReadingListBatchUpdate { 102 class ScopedReadingListBatchUpdate {
99 public: 103 public:
100 explicit ScopedReadingListBatchUpdate(ReadingListModel* model) 104 explicit ScopedReadingListBatchUpdate(ReadingListModel* model)
101 : model_(model) {} 105 : model_(model) {}
102 106
103 ~ScopedReadingListBatchUpdate() { model_->EndBatchUpdates(); } 107 ~ScopedReadingListBatchUpdate() { model_->EndBatchUpdates(); }
104 108
105 private: 109 private:
106 ReadingListModel* model_; 110 ReadingListModel* model_;
107 111
108 DISALLOW_COPY_AND_ASSIGN(ScopedReadingListBatchUpdate); 112 DISALLOW_COPY_AND_ASSIGN(ScopedReadingListBatchUpdate);
109 }; 113 };
110 114
115 // Remove all reading list entries. Used for tests only.
Olivier 2016/10/20 11:25:39 Removes Do you need this in the public interface?
gambard 2016/10/20 11:51:35 Done. I need this for EG test. If you see a better
Olivier 2016/10/20 13:38:02 Unittests use directly ReadingListModelImpl, so yo
gambard 2016/10/20 15:43:05 Done.
116 virtual void ClearModelForTest() = 0;
117
111 protected: 118 protected:
112 ReadingListModel(); 119 ReadingListModel();
113 virtual ~ReadingListModel(); 120 virtual ~ReadingListModel();
114 121
115 // The observers. 122 // The observers.
116 base::ObserverList<ReadingListModelObserver> observers_; 123 base::ObserverList<ReadingListModelObserver> observers_;
117 124
118 // Tells model that batch updates have completed. Called from 125 // Tells model that batch updates have completed. Called from
119 // ReadingListBatchUpdateToken dtor. 126 // ReadingListBatchUpdateToken dtor.
120 virtual void EndBatchUpdates(); 127 virtual void EndBatchUpdates();
121 128
122 private: 129 private:
123 unsigned int current_batch_updates_count_; 130 unsigned int current_batch_updates_count_;
124 131
125 DISALLOW_COPY_AND_ASSIGN(ReadingListModel); 132 DISALLOW_COPY_AND_ASSIGN(ReadingListModel);
126 }; 133 };
127 134
128 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ 135 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698