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

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

Issue 2870753003: Add a Model to the download component. (Closed)
Patch Set: Renamed test base class 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/noop_store.cc ('k') | components/download/internal/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « components/download/internal/noop_store.cc ('k') | components/download/internal/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698