Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 10 matching lines...) Expand all Loading... | |
| 21 class ChromeBrowserState; | 21 class ChromeBrowserState; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // The reading list model contains two list of entries: one of unread urls, the | 24 // The reading list model contains two list of entries: one of unread urls, the |
| 25 // other of read ones. This object should only be accessed from one thread | 25 // other of read ones. This object should only be accessed from one thread |
| 26 // (Usually the main thread). The observers callbacks are also sent on the main | 26 // (Usually the main thread). The observers callbacks are also sent on the main |
| 27 // thread. | 27 // thread. |
| 28 class ReadingListModel { | 28 class ReadingListModel { |
| 29 public: | 29 public: |
| 30 class ScopedReadingListBatchUpdate; | 30 class ScopedReadingListBatchUpdate; |
| 31 | |
| 32 // The entry is either NOT_PRESENT in the model, in the READ part or in the | |
| 33 // UNREAD part of the model. | |
| 34 enum EntryState { NOT_PRESENT, READ, UNREAD }; | |
| 35 | |
| 31 // Returns true if the model finished loading. Until this returns true the | 36 // Returns true if the model finished loading. Until this returns true the |
| 32 // reading list is not ready for use. | 37 // reading list is not ready for use. |
| 33 virtual bool loaded() const = 0; | 38 virtual bool loaded() const = 0; |
| 34 | 39 |
| 35 // Returns true if the model is performing batch updates right now. | 40 // Returns true if the model is performing batch updates right now. |
| 36 bool IsPerformingBatchUpdates() const; | 41 bool IsPerformingBatchUpdates() const; |
| 37 | 42 |
| 38 // Tells model to prepare for batch updates. | 43 // Tells model to prepare for batch updates. |
| 39 // This method is reentrant, i.e. several batch updates may take place at the | 44 // This method is reentrant, i.e. several batch updates may take place at the |
| 40 // same time. | 45 // same time. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 | 78 |
| 74 // Removes an entry. The removal may be asynchronous, and not happen | 79 // Removes an entry. The removal may be asynchronous, and not happen |
| 75 // immediately. | 80 // immediately. |
| 76 virtual void RemoveEntryByUrl(const GURL& url) = 0; | 81 virtual void RemoveEntryByUrl(const GURL& url) = 0; |
| 77 | 82 |
| 78 // If the |url| is in the reading list and unread, mark it read. If it is in | 83 // 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 | 84 // 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. | 85 // already. This may trigger deletion of old read entries. |
| 81 virtual void MarkReadByURL(const GURL& url) = 0; | 86 virtual void MarkReadByURL(const GURL& url) = 0; |
| 82 | 87 |
| 88 // Return the state of the entry in the model (not present, read or unread). | |
| 89 virtual EntryState EntryStateByURL(const GURL& url) = 0; | |
|
Olivier
2016/09/27 08:55:33
How will this be used differently from CallbackEnt
gambard
2016/09/27 15:59:34
This is just to know if it exists an entry with th
noyau (Ping after 24h)
2016/10/04 09:13:26
There is no reason to have two methods doing the s
| |
| 90 | |
| 83 // Methods to mutate an entry. Will locate the relevant entry by URL. Does | 91 // Methods to mutate an entry. Will locate the relevant entry by URL. Does |
| 84 // nothing if the entry is not found. | 92 // nothing if the entry is not found. |
| 85 virtual void SetEntryTitle(const GURL& url, const std::string& title) = 0; | 93 virtual void SetEntryTitle(const GURL& url, const std::string& title) = 0; |
| 86 virtual void SetEntryDistilledURL(const GURL& url, | 94 virtual void SetEntryDistilledURL(const GURL& url, |
| 87 const GURL& distilled_url) = 0; | 95 const GURL& distilled_url) = 0; |
| 88 virtual void SetEntryDistilledState( | 96 virtual void SetEntryDistilledState( |
| 89 const GURL& url, | 97 const GURL& url, |
| 90 ReadingListEntry::DistillationState state) = 0; | 98 ReadingListEntry::DistillationState state) = 0; |
| 91 | 99 |
| 92 // Observer registration methods. | 100 // Observer registration methods. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 118 // ReadingListBatchUpdateToken dtor. | 126 // ReadingListBatchUpdateToken dtor. |
| 119 virtual void EndBatchUpdates(); | 127 virtual void EndBatchUpdates(); |
| 120 | 128 |
| 121 private: | 129 private: |
| 122 unsigned int current_batch_updates_count_; | 130 unsigned int current_batch_updates_count_; |
| 123 | 131 |
| 124 DISALLOW_COPY_AND_ASSIGN(ReadingListModel); | 132 DISALLOW_COPY_AND_ASSIGN(ReadingListModel); |
| 125 }; | 133 }; |
| 126 | 134 |
| 127 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ | 135 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ |
| OLD | NEW |