OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_ |
| 6 #define COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/callback_forward.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/sequenced_task_runner.h" |
| 15 |
| 16 namespace download { |
| 17 |
| 18 struct Entry; |
| 19 |
| 20 // A backing storage interface responsible for persisting Entry objects. |
| 21 class Store { |
| 22 public: |
| 23 using InitCallback = |
| 24 base::OnceCallback<void(bool success, |
| 25 std::unique_ptr<std::vector<Entry>> entries)>; |
| 26 using StoreCallback = base::OnceCallback<void(bool success)>; |
| 27 |
| 28 virtual ~Store() = default; |
| 29 |
| 30 // Returns whether or not this Store is initialized and can be interracted |
| 31 // with. |
| 32 virtual bool IsInitialized() = 0; |
| 33 |
| 34 // Initializes this Store and asynchronously returns whether or not that |
| 35 // initialization was successful as well as a list of Entry objects from the |
| 36 // Store. |
| 37 virtual void Initialize(InitCallback callback) = 0; |
| 38 |
| 39 // Destroyes the store and asynchronously returns whether or not that |
| 40 // destruction was successful. |
| 41 virtual void Destroy(StoreCallback callback) = 0; |
| 42 |
| 43 // Adds or updates |entry| in this Store asynchronously and returns whether or |
| 44 // not that was successful. |
| 45 virtual void Update(const Entry& entry, StoreCallback callback) = 0; |
| 46 |
| 47 // Removes the Entry associated with |guid| from this Store asynchronously and |
| 48 // returns whether or not that was successful. |
| 49 virtual void Remove(const std::string& guid, StoreCallback callback) = 0; |
| 50 }; |
| 51 |
| 52 } // namespace download |
| 53 |
| 54 #endif // COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_ |
OLD | NEW |