Index: ios/chrome/browser/reading_list/reading_list_store.h |
diff --git a/ios/chrome/browser/reading_list/reading_list_store.h b/ios/chrome/browser/reading_list/reading_list_store.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dcdba4bd404ffa7a6d1f7eea9d0975734b2b69fc |
--- /dev/null |
+++ b/ios/chrome/browser/reading_list/reading_list_store.h |
@@ -0,0 +1,53 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_STORE_H_ |
+#define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_STORE_H_ |
+ |
+#include "base/containers/hash_tables.h" |
+#include "base/files/file_path.h" |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/observer_list.h" |
+#include "components/leveldb_proto/proto_database.h" |
+#include "components/sync/protocol/reading_list_specifics.pb.h" |
+#include "ios/chrome/browser/reading_list/reading_list_model_storage.h" |
+#include "url/gurl.h" |
+ |
+typedef leveldb_proto::ProtoDatabase<sync_pb::ReadingListLocal> ReadingListDB; |
jif-google
2016/09/27 16:39:03
s/typedef/using/
|
+ |
+class ReadingListStore : public ReadingListModelStorage { |
gambard
2016/09/28 09:19:08
Comment here and for the methods?
|
+ typedef std::vector<sync_pb::ReadingListLocal> EntryVector; |
+ |
+ public: |
+ ReadingListStore(std::unique_ptr<ReadingListDB> database, |
+ const base::FilePath& database_dir); |
+ virtual ~ReadingListStore(); |
+ |
+ void SetReadingListModel(ReadingListModelImpl* model) override; |
+ |
+ void BeginTransaction() override; |
+ void CommitTransaction() override; |
+ |
+ void LoadPersistentLists() override; |
+ void SaveEntry(const ReadingListEntry& entry, bool read) override; |
+ void RemoveEntry(const ReadingListEntry& entry) override; |
+ |
+ private: |
+ void OnDatabaseInit(bool success); |
+ void OnDatabaseLoad(bool success, std::unique_ptr<EntryVector> entries); |
+ void OnDatabaseSave(bool success); |
+ |
+ std::unique_ptr<ReadingListDB> database_; |
+ bool database_loaded_; |
+ ReadingListModelImpl* model_; |
+ |
+ int pending_transaction_; |
+ std::unique_ptr<ReadingListDB::KeyEntryVector> pending_keys_to_save_; |
+ std::unique_ptr<std::vector<std::string>> pending_keys_to_remove_; |
+ |
+ base::WeakPtrFactory<ReadingListStore> weak_ptr_factory_; |
+}; |
+ |
+#endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_STORE_H_ |