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