| 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 class PrefService; |
| 15 | 16 |
| 16 // Concrete implementation of a reading list model using in memory lists. | 17 // Concrete implementation of a reading list model using in memory lists. |
| 17 class ReadingListModelImpl : public ReadingListModel, public KeyedService { | 18 class ReadingListModelImpl : public ReadingListModel, public KeyedService { |
| 18 public: | 19 public: |
| 19 // Initialize a ReadingListModelImpl to load and save data in | 20 // Initialize a ReadingListModelImpl to load and save data in |
| 20 // |persistence_layer|. | 21 // |persistence_layer|. |
| 21 ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer); | 22 ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer, |
| 23 PrefService* pref_service); |
| 22 | 24 |
| 23 // Initialize a ReadingListModelImpl without persistence. Data will not be | 25 // Initialize a ReadingListModelImpl without persistence. Data will not be |
| 24 // persistent across sessions. | 26 // persistent across sessions. |
| 25 ReadingListModelImpl(); | 27 ReadingListModelImpl(); |
| 26 | 28 |
| 27 ~ReadingListModelImpl() override; | 29 ~ReadingListModelImpl() override; |
| 28 void Shutdown() override; | 30 void Shutdown() override; |
| 29 | 31 |
| 30 bool loaded() const override; | 32 bool loaded() const override; |
| 31 | 33 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 50 | 52 |
| 51 void MarkReadByURL(const GURL& url) override; | 53 void MarkReadByURL(const GURL& url) override; |
| 52 | 54 |
| 53 void SetEntryTitle(const GURL& url, const std::string& title) override; | 55 void SetEntryTitle(const GURL& url, const std::string& title) override; |
| 54 void SetEntryDistilledURL(const GURL& url, | 56 void SetEntryDistilledURL(const GURL& url, |
| 55 const GURL& distilled_url) override; | 57 const GURL& distilled_url) override; |
| 56 void SetEntryDistilledState( | 58 void SetEntryDistilledState( |
| 57 const GURL& url, | 59 const GURL& url, |
| 58 ReadingListEntry::DistillationState state) override; | 60 ReadingListEntry::DistillationState state) override; |
| 59 | 61 |
| 62 virtual void ModelLoaded(std::unique_ptr<ReadingListEntries> unread, |
| 63 std::unique_ptr<ReadingListEntries> read); |
| 64 |
| 60 protected: | 65 protected: |
| 61 void EndBatchUpdates() override; | 66 void EnteringBatchUpdates() override; |
| 67 void LeavingBatchUpdates() override; |
| 62 | 68 |
| 63 private: | 69 private: |
| 64 typedef std::vector<ReadingListEntry> ReadingListEntries; | 70 void SavePersistentHasUnseen(bool has_unseen); |
| 71 bool LoadPersistentHasUnseen(); |
| 65 | 72 |
| 66 ReadingListEntries unread_; | 73 std::unique_ptr<ReadingListEntries> unread_; |
| 67 ReadingListEntries read_; | 74 std::unique_ptr<ReadingListEntries> read_; |
| 68 std::unique_ptr<ReadingListModelStorage> storageLayer_; | 75 std::unique_ptr<ReadingListModelStorage> storage_layer_; |
| 69 bool hasUnseen_; | 76 PrefService* pref_service_; |
| 77 bool has_unseen_; |
| 70 bool loaded_; | 78 bool loaded_; |
| 71 | 79 base::WeakPtrFactory<ReadingListModelImpl> weak_ptr_factory_; |
| 72 DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl); | 80 DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl); |
| 73 }; | 81 }; |
| 74 | 82 |
| 75 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_MEMORY_H_ | 83 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_MODEL_MEMORY_H_ |
| OLD | NEW |