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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "ios/chrome/browser/reading_list/reading_list_entry.h" | 14 #include "ios/chrome/browser/reading_list/reading_list_entry.h" |
15 #include "ios/chrome/browser/reading_list/reading_list_model_observer.h" | 15 #include "ios/chrome/browser/reading_list/reading_list_model_observer.h" |
16 | 16 |
17 class GURL; | 17 class GURL; |
18 class ReadingListModel; | 18 class ReadingListModel; |
19 class ReadingListStore; | 19 class ReadingListStore; |
20 | 20 |
21 namespace ios { | 21 namespace ios { |
22 class ChromeBrowserState; | 22 class ChromeBrowserState; |
23 } | 23 } |
24 | 24 |
25 namespace syncer { | 25 namespace syncer { |
26 class SyncableService; | 26 class ModelTypeService; |
27 } | 27 } |
28 | 28 |
29 // The reading list model contains two list of entries: one of unread urls, the | 29 // The reading list model contains two list of entries: one of unread urls, the |
30 // other of read ones. This object should only be accessed from one thread | 30 // other of read ones. This object should only be accessed from one thread |
31 // (Usually the main thread). The observers callbacks are also sent on the main | 31 // (Usually the main thread). The observers callbacks are also sent on the main |
32 // thread. | 32 // thread. |
33 class ReadingListModel { | 33 class ReadingListModel { |
34 public: | 34 public: |
35 class ScopedReadingListBatchUpdate; | 35 class ScopedReadingListBatchUpdate; |
36 // 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 |
37 // reading list is not ready for use. | 37 // reading list is not ready for use. |
38 virtual bool loaded() const = 0; | 38 virtual bool loaded() const = 0; |
39 | 39 |
40 // Returns true if the model is performing batch updates right now. | 40 // Returns true if the model is performing batch updates right now. |
41 bool IsPerformingBatchUpdates() const; | 41 bool IsPerformingBatchUpdates() const; |
42 | 42 |
| 43 virtual syncer::ModelTypeService* GetModelTypeService() = 0; |
| 44 |
43 // Tells model to prepare for batch updates. | 45 // Tells model to prepare for batch updates. |
44 // This method is reentrant, i.e. several batch updates may take place at the | 46 // This method is reentrant, i.e. several batch updates may take place at the |
45 // same time. | 47 // same time. |
46 // Returns a scoped batch update object that should be retained while the | 48 // Returns a scoped batch update object that should be retained while the |
47 // batch update is performed. Deallocating this object will inform model that | 49 // batch update is performed. Deallocating this object will inform model that |
48 // the batch update has completed. | 50 // the batch update has completed. |
49 std::unique_ptr<ScopedReadingListBatchUpdate> BeginBatchUpdates(); | 51 std::unique_ptr<ScopedReadingListBatchUpdate> BeginBatchUpdates(); |
50 | 52 |
51 // Returns the size of read and unread entries. | 53 // Returns the size of read and unread entries. |
52 virtual size_t unread_size() const = 0; | 54 virtual size_t unread_size() const = 0; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // Called when model is leaving batch update mode. | 131 // Called when model is leaving batch update mode. |
130 virtual void LeavingBatchUpdates(); | 132 virtual void LeavingBatchUpdates(); |
131 | 133 |
132 private: | 134 private: |
133 unsigned int current_batch_updates_count_; | 135 unsigned int current_batch_updates_count_; |
134 | 136 |
135 DISALLOW_COPY_AND_ASSIGN(ReadingListModel); | 137 DISALLOW_COPY_AND_ASSIGN(ReadingListModel); |
136 }; | 138 }; |
137 | 139 |
138 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ | 140 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_H_ |
OLD | NEW |