Chromium Code Reviews| 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..8d8230a92991dbb0090fd8965f858e2b84a2e645 |
| --- /dev/null |
| +++ b/components/download/internal/store.h |
| @@ -0,0 +1,55 @@ |
| +// 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::Callback<void(bool success, |
| + std::unique_ptr<std::vector<Entry>> entries)>; |
| + using StoreCallback = base::Callback<void(bool success)>; |
|
Peter Beverloo
2017/05/10 12:44:45
nit: these can be base::OnceCallback, allowing you
David Trainor- moved to gerrit
2017/05/15 15:59:52
Done.
|
| + |
| + 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(const InitCallback& callback) = 0; |
| + |
| + // Destroyes the store and asynchronously returns whether or not that |
| + // destruction was successful. |
| + virtual void Destroy(const 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, const 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, |
| + const StoreCallback& callback) = 0; |
| +}; |
| + |
| +} // namespace download |
| + |
| +#endif // COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_ |