Chromium Code Reviews| 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..da2636719eee7cdf272c1b92c7cf3a1cd361c01c |
| --- /dev/null |
| +++ b/ios/chrome/browser/reading_list/reading_list_store.h |
| @@ -0,0 +1,48 @@ |
| +// 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/memory/weak_ptr.h" |
| +#include "components/leveldb_proto/proto_database.h" |
| +#include "ios/chrome/browser/reading_list/reading_list_model_storage.h" |
| + |
| +using ReadingListDB = |
| + leveldb_proto::ProtoDatabase<reading_list::ReadingListLocal>; |
| + |
| +// A ReadingListModelStorage storing data in protobufs. |
| +class ReadingListStore : public ReadingListModelStorage { |
| + using EntryVector = std::vector<reading_list::ReadingListLocal>; |
| + |
| + public: |
| + ReadingListStore(std::unique_ptr<ReadingListDB> database, |
| + const base::FilePath& database_dir); |
| + virtual ~ReadingListStore(); |
| + |
| + // ReadingListModelStorage implementation |
| + 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_; |
|
Olivier
2016/10/06 11:58:15
This will become a ModelTypeStore with USS
|
| + 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_ |