OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_STORE_H_ | |
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_STORE_H_ | |
7 | |
8 #include "base/containers/hash_tables.h" | |
9 #include "base/files/file_path.h" | |
10 #include "base/macros.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/observer_list.h" | |
13 #include "components/leveldb_proto/proto_database.h" | |
14 #include "components/sync/protocol/reading_list_specifics.pb.h" | |
15 #include "ios/chrome/browser/reading_list/reading_list_model_storage.h" | |
16 #include "url/gurl.h" | |
17 | |
18 typedef leveldb_proto::ProtoDatabase<sync_pb::ReadingListLocal> ReadingListDB; | |
jif-google
2016/09/27 16:39:03
s/typedef/using/
| |
19 | |
20 class ReadingListStore : public ReadingListModelStorage { | |
gambard
2016/09/28 09:19:08
Comment here and for the methods?
| |
21 typedef std::vector<sync_pb::ReadingListLocal> EntryVector; | |
22 | |
23 public: | |
24 ReadingListStore(std::unique_ptr<ReadingListDB> database, | |
25 const base::FilePath& database_dir); | |
26 virtual ~ReadingListStore(); | |
27 | |
28 void SetReadingListModel(ReadingListModelImpl* model) override; | |
29 | |
30 void BeginTransaction() override; | |
31 void CommitTransaction() override; | |
32 | |
33 void LoadPersistentLists() override; | |
34 void SaveEntry(const ReadingListEntry& entry, bool read) override; | |
35 void RemoveEntry(const ReadingListEntry& entry) override; | |
36 | |
37 private: | |
38 void OnDatabaseInit(bool success); | |
39 void OnDatabaseLoad(bool success, std::unique_ptr<EntryVector> entries); | |
40 void OnDatabaseSave(bool success); | |
41 | |
42 std::unique_ptr<ReadingListDB> database_; | |
43 bool database_loaded_; | |
44 ReadingListModelImpl* model_; | |
45 | |
46 int pending_transaction_; | |
47 std::unique_ptr<ReadingListDB::KeyEntryVector> pending_keys_to_save_; | |
48 std::unique_ptr<std::vector<std::string>> pending_keys_to_remove_; | |
49 | |
50 base::WeakPtrFactory<ReadingListStore> weak_ptr_factory_; | |
51 }; | |
52 | |
53 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_STORE_H_ | |
OLD | NEW |