Index: components/download/internal/store.h |
diff --git a/components/download/internal/store.h b/components/download/internal/store.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..04a39bffcc6ee7b0cab733d46cbe90bbd32d8af6 |
--- /dev/null |
+++ b/components/download/internal/store.h |
@@ -0,0 +1,54 @@ |
+// 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_STORE_H_ |
+#define COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_ |
+ |
+#include <memory> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/callback_forward.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/sequenced_task_runner.h" |
+ |
+namespace download { |
+ |
+struct Entry; |
+ |
+// A backing storage interface responsible for persisting Entry objects. |
+class Store { |
+ public: |
+ using InitCallback = |
+ base::OnceCallback<void(bool success, |
+ std::unique_ptr<std::vector<Entry>> entries)>; |
+ using StoreCallback = base::OnceCallback<void(bool success)>; |
+ |
+ virtual ~Store() = default; |
+ |
+ // Returns whether or not this Store is initialized and can be interracted |
+ // with. |
+ virtual bool IsInitialized() = 0; |
+ |
+ // Initializes this Store and asynchronously returns whether or not that |
+ // initialization was successful as well as a list of Entry objects from the |
+ // Store. |
+ virtual void Initialize(InitCallback callback) = 0; |
+ |
+ // Destroyes the store and asynchronously returns whether or not that |
+ // destruction was successful. |
+ virtual void Destroy(StoreCallback callback) = 0; |
+ |
+ // Adds or updates |entry| in this Store asynchronously and returns whether or |
+ // not that was successful. |
+ virtual void Update(const Entry& entry, StoreCallback callback) = 0; |
+ |
+ // Removes the Entry associated with |guid| from this Store asynchronously and |
+ // returns whether or not that was successful. |
+ virtual void Remove(const std::string& guid, StoreCallback callback) = 0; |
+}; |
+ |
+} // namespace download |
+ |
+#endif // COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_ |