| 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..a5eefa098dca2bc11ef87950ef35a41459c943bb
|
| --- /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"
|
| +
|
| +using ReadingListDB = leveldb_proto::ProtoDatabase<sync_pb::ReadingListLocal>;
|
| +
|
| +// A ReadingListModelStorage storing data in protobufs.
|
| +class ReadingListStore : public ReadingListModelStorage {
|
| + using EntryVector = std::vector<sync_pb::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_;
|
| + 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_
|
|
|