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

Unified Diff: components/download/internal/download_store.h

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: Removed Model::Destroy Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/download/internal/DEPS ('k') | components/download/internal/download_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/download/internal/download_store.h
diff --git a/components/download/internal/download_store.h b/components/download/internal/download_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..e662e80cb327f0d25e0e2c91e2bd2633c292b4d4
--- /dev/null
+++ b/components/download/internal/download_store.h
@@ -0,0 +1,58 @@
+// Copyright 2017 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 COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_STORE_H_
+#define COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_STORE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "components/download/internal/store.h"
+#include "components/leveldb_proto/proto_database.h"
+
+namespace protodb {
+class Entry;
+
+} // namespace
+
+namespace download {
+
+// DownloadStore provides a layer around a LevelDB proto database that persists
+// the download request, scheduling params and metadata to the disk. The data is
+// read during initialization and presented to the caller after converting to
+// Entry entries.
+class DownloadStore : public Store {
+ public:
+ DownloadStore(
+ const base::FilePath& database_dir,
+ std::unique_ptr<leveldb_proto::ProtoDatabase<protodb::Entry>> db);
+ ~DownloadStore() override;
+
+ // Store implementation.
+ bool IsInitialized() override;
+ void Initialize(InitCallback callback) override;
+ void Update(const Entry& entry, StoreCallback callback) override;
+ void Remove(const std::string& guid, StoreCallback callback) override;
+
+ private:
+ void OnDatabaseInited(InitCallback callback, bool success);
+ void OnDatabaseLoaded(InitCallback callback,
+ bool success,
+ std::unique_ptr<std::vector<protodb::Entry>> protos);
+
+ std::unique_ptr<leveldb_proto::ProtoDatabase<protodb::Entry>> db_;
+ base::FilePath database_dir_;
+ bool is_initialized_;
+
+ base::WeakPtrFactory<DownloadStore> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadStore);
+};
+
+} // namespace download
+
+#endif // COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_STORE_H_
« no previous file with comments | « components/download/internal/DEPS ('k') | components/download/internal/download_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698