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

Side by Side Diff: components/reading_list/ios/reading_list_model_impl.h

Issue 2764533002: Reading List iOS: Use external clock in ReadingListEntry. (Closed)
Patch Set: jitter Created 3 years, 9 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 COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_IMPL_H_ 5 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_IMPL_H_
6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_IMPL_H_ 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "components/keyed_service/core/keyed_service.h" 11 #include "components/keyed_service/core/keyed_service.h"
12 #include "components/reading_list/ios/reading_list_entry.h" 12 #include "components/reading_list/ios/reading_list_entry.h"
13 #include "components/reading_list/ios/reading_list_model.h" 13 #include "components/reading_list/ios/reading_list_model.h"
14 #include "components/reading_list/ios/reading_list_model_storage.h" 14 #include "components/reading_list/ios/reading_list_model_storage.h"
15 #include "components/reading_list/ios/reading_list_store_delegate.h" 15 #include "components/reading_list/ios/reading_list_store_delegate.h"
16 16
17 namespace base {
18 class Clock;
19 }
20
17 class PrefService; 21 class PrefService;
18 22
19 // Concrete implementation of a reading list model using in memory lists. 23 // Concrete implementation of a reading list model using in memory lists.
20 class ReadingListModelImpl : public ReadingListModel, 24 class ReadingListModelImpl : public ReadingListModel,
21 public ReadingListStoreDelegate, 25 public ReadingListStoreDelegate,
22 public KeyedService { 26 public KeyedService {
23 public: 27 public:
24 using ReadingListEntries = std::map<GURL, ReadingListEntry>; 28 using ReadingListEntries = std::map<GURL, ReadingListEntry>;
25 29
26 // Initialize a ReadingListModelImpl to load and save data in 30 // Initialize a ReadingListModelImpl to load and save data in
27 // |persistence_layer|. 31 // |storage_layer|. Passing null to |storage_layer| will create a
32 // ReadingListModelImpl without persistence. Data will not be persistent
33 // across sessions.
34 // |clock| will be used to timestamp all the operations.
28 ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer, 35 ReadingListModelImpl(std::unique_ptr<ReadingListModelStorage> storage_layer,
29 PrefService* pref_service); 36 PrefService* pref_service,
37 std::unique_ptr<base::Clock> clock_);
30 38
31 // Initialize a ReadingListModelImpl without persistence. Data will not be
32 // persistent across sessions.
33 ReadingListModelImpl(); 39 ReadingListModelImpl();
34 40
35 syncer::ModelTypeSyncBridge* GetModelTypeSyncBridge() override; 41 syncer::ModelTypeSyncBridge* GetModelTypeSyncBridge() override;
36 42
37 ~ReadingListModelImpl() override; 43 ~ReadingListModelImpl() override;
38 44
39 void StoreLoaded(std::unique_ptr<ReadingListEntries> entries) override; 45 void StoreLoaded(std::unique_ptr<ReadingListEntries> entries) override;
40 46
41 // KeyedService implementation. 47 // KeyedService implementation.
42 void Shutdown() override; 48 void Shutdown() override;
(...skipping 23 matching lines...) Expand all
66 void SetReadStatus(const GURL& url, bool read) override; 72 void SetReadStatus(const GURL& url, bool read) override;
67 73
68 void SetEntryTitle(const GURL& url, const std::string& title) override; 74 void SetEntryTitle(const GURL& url, const std::string& title) override;
69 void SetEntryDistilledState( 75 void SetEntryDistilledState(
70 const GURL& url, 76 const GURL& url,
71 ReadingListEntry::DistillationState state) override; 77 ReadingListEntry::DistillationState state) override;
72 void SetEntryDistilledInfo(const GURL& url, 78 void SetEntryDistilledInfo(const GURL& url,
73 const base::FilePath& distilled_path, 79 const base::FilePath& distilled_path,
74 const GURL& distilled_url, 80 const GURL& distilled_url,
75 int64_t distillation_size, 81 int64_t distillation_size,
76 int64_t distillation_date) override; 82 const base::Time& distillation_date) override;
77 83
78 void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry) override; 84 void SyncAddEntry(std::unique_ptr<ReadingListEntry> entry) override;
79 ReadingListEntry* SyncMergeEntry( 85 ReadingListEntry* SyncMergeEntry(
80 std::unique_ptr<ReadingListEntry> entry) override; 86 std::unique_ptr<ReadingListEntry> entry) override;
81 void SyncRemoveEntry(const GURL& url) override; 87 void SyncRemoveEntry(const GURL& url) override;
82 88
83 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> 89 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate>
84 CreateBatchToken() override; 90 CreateBatchToken() override;
85 91
86 // Helper class that is used to scope batch updates. 92 // Helper class that is used to scope batch updates.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 size_t read_entry_count_; 130 size_t read_entry_count_;
125 size_t unseen_entry_count_; 131 size_t unseen_entry_count_;
126 132
127 // Update the 3 counts above considering addition/removal of |entry|. 133 // Update the 3 counts above considering addition/removal of |entry|.
128 void UpdateEntryStateCountersOnEntryRemoval(const ReadingListEntry& entry); 134 void UpdateEntryStateCountersOnEntryRemoval(const ReadingListEntry& entry);
129 void UpdateEntryStateCountersOnEntryInsertion(const ReadingListEntry& entry); 135 void UpdateEntryStateCountersOnEntryInsertion(const ReadingListEntry& entry);
130 136
131 // Set the unseen flag to true. 137 // Set the unseen flag to true.
132 void SetUnseenFlag(); 138 void SetUnseenFlag();
133 139
140 // |storage_layer_| depends on |clock_| so keep the order.
141 std::unique_ptr<base::Clock> clock_;
134 std::unique_ptr<ReadingListModelStorage> storage_layer_; 142 std::unique_ptr<ReadingListModelStorage> storage_layer_;
135 PrefService* pref_service_; 143 PrefService* pref_service_;
136 bool has_unseen_; 144 bool has_unseen_;
137 bool loaded_; 145 bool loaded_;
146
138 base::WeakPtrFactory<ReadingListModelImpl> weak_ptr_factory_; 147 base::WeakPtrFactory<ReadingListModelImpl> weak_ptr_factory_;
148
139 DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl); 149 DISALLOW_COPY_AND_ASSIGN(ReadingListModelImpl);
140 }; 150 };
141 151
142 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_IMPL_H_ 152 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_IMPL_H_
OLDNEW
« no previous file with comments | « components/reading_list/ios/reading_list_model.h ('k') | components/reading_list/ios/reading_list_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698