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_IMPL_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_IMPL_H_ |
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_IMPL_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
11 #include "ios/chrome/browser/reading_list/reading_list_entry.h" | 11 #include "ios/chrome/browser/reading_list/reading_list_entry.h" |
12 #include "ios/chrome/browser/reading_list/reading_list_model.h" | 12 #include "ios/chrome/browser/reading_list/reading_list_model.h" |
13 | 13 |
14 class ReadingListModelStorage; | 14 class ReadingListModelStorage; |
15 | 15 |
16 // Concrete implementation of a reading list model using in memory lists. | 16 // Concrete implementation of a reading list model using in memory lists. |
17 class ReadingListModelImpl : public ReadingListModel, public KeyedService { | 17 class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
18 public: | 18 public: |
19 // Initialize a ReadingListModelImpl to load and save data in | 19 // Initialize a ReadingListModelImpl to load and save data in |
20 // |persistence_layer|. | 20 // |persistence_layer|. |
21 ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer); | 21 ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer); |
22 | 22 |
23 // Initialize a ReadingListModelImpl without persistence. Data will not be | 23 // Initialize a ReadingListModelImpl without persistence. Data will not be |
24 // persistent across sessions. | 24 // persistent across sessions. |
25 ReadingListModelImpl(); | 25 ReadingListModelImpl(); |
26 | 26 |
27 ~ReadingListModelImpl() override; | 27 ~ReadingListModelImpl() override; |
| 28 |
| 29 // KeyedService implementation. |
28 void Shutdown() override; | 30 void Shutdown() override; |
29 | 31 |
| 32 // ReadingListModel implementation. |
30 bool loaded() const override; | 33 bool loaded() const override; |
31 | 34 |
32 size_t unread_size() const override; | 35 size_t unread_size() const override; |
33 size_t read_size() const override; | 36 size_t read_size() const override; |
34 | 37 |
35 bool HasUnseenEntries() const override; | 38 bool HasUnseenEntries() const override; |
36 void ResetUnseenEntries() override; | 39 void ResetUnseenEntries() override; |
37 | 40 |
38 // Returns a specific entry. | 41 const ReadingListEntry* GetUnreadEntryAtIndex(size_t index) const override; |
39 const ReadingListEntry& GetUnreadEntryAtIndex(size_t index) const override; | 42 const ReadingListEntry* GetReadEntryAtIndex(size_t index) const override; |
40 const ReadingListEntry& GetReadEntryAtIndex(size_t index) const override; | 43 const ReadingListEntry* GetEntryFromURL(const GURL& gurl) const override; |
41 | 44 |
42 bool CallbackEntryURL( | 45 bool CallbackEntryURL( |
43 const GURL& url, | 46 const GURL& url, |
44 base::Callback<void(const ReadingListEntry&)> callback) const override; | 47 base::Callback<void(const ReadingListEntry&)> callback) const override; |
45 | 48 |
46 void RemoveEntryByUrl(const GURL& url) override; | 49 void RemoveEntryByUrl(const GURL& url) override; |
47 | 50 |
48 const ReadingListEntry& AddEntry(const GURL& url, | 51 const ReadingListEntry& AddEntry(const GURL& url, |
49 const std::string& title) override; | 52 const std::string& title) override; |
50 | 53 |
(...skipping 15 matching lines...) Expand all Loading... |
66 ReadingListEntries unread_; | 69 ReadingListEntries unread_; |
67 ReadingListEntries read_; | 70 ReadingListEntries read_; |
68 std::unique_ptr<ReadingListModelStorage> storageLayer_; | 71 std::unique_ptr<ReadingListModelStorage> storageLayer_; |
69 bool hasUnseen_; | 72 bool hasUnseen_; |
70 bool loaded_; | 73 bool loaded_; |
71 | 74 |
72 DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl); | 75 DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl); |
73 }; | 76 }; |
74 | 77 |
75 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_MEMORY_H_ | 78 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_MEMORY_H_ |
OLD | NEW |