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

Side by Side Diff: components/download/internal/store.h

Issue 2870753003: Add a Model to the download component. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(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::Callback<void(bool success,
25 std::unique_ptr<std::vector<Entry>> entries)>;
26 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.
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(const InitCallback& callback) = 0;
38
39 // Destroyes the store and asynchronously returns whether or not that
40 // destruction was successful.
41 virtual void Destroy(const 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, const 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,
50 const StoreCallback& callback) = 0;
51 };
52
53 } // namespace download
54
55 #endif // COMPONENTS_DOWNLOAD_INTERNAL_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698