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

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

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

Powered by Google App Engine
This is Rietveld 408576698