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

Side by Side Diff: components/offline_pages/background/request_queue_store.h

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years 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 2016 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_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
7
8 #include <stdint.h>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "components/offline_pages/background/request_queue.h"
13 #include "components/offline_pages/background/save_page_request.h"
14 #include "components/offline_pages/offline_store_types.h"
15
16 namespace offline_pages {
17
18 // Interface for classes storing save page requests.
19 class RequestQueueStore {
20 public:
21 enum class UpdateStatus {
22 ADDED, // Request was added successfully.
23 UPDATED, // Request was updated successfully.
24 FAILED, // Add or update attempt failed.
25 };
26
27 using UpdateCallback = RequestQueue::UpdateCallback;
28
29 typedef base::Callback<void(bool /* success */)> InitializeCallback;
30 typedef base::Callback<void(bool /* success */)> ResetCallback;
31 typedef base::Callback<void(
32 bool /* success */,
33 std::vector<std::unique_ptr<SavePageRequest>> /* requests */)>
34 GetRequestsCallback;
35 typedef base::Callback<void(ItemActionStatus)> AddCallback;
36
37 virtual ~RequestQueueStore(){};
38
39 // Initializes the store. Should be called before any other methods.
40 virtual void Initialize(const InitializeCallback& callback) = 0;
41
42 // Gets all of the requests from the store.
43 virtual void GetRequests(const GetRequestsCallback& callback) = 0;
44
45 // Gets requests with specified IDs from the store. UpdateCallback is used
46 // instead of GetRequestsCallback to indicate which requests where not found.
47 virtual void GetRequestsByIds(const std::vector<int64_t>& request_ids,
48 const UpdateCallback& callback) = 0;
49
50 // Asynchronously adds request in store. Fails if request with the same
51 // offline ID already exists.
52 virtual void AddRequest(const SavePageRequest& offline_page,
53 const AddCallback& callback) = 0;
54
55 // Asynchronously updates requests in store.
56 virtual void UpdateRequests(const std::vector<SavePageRequest>& requests,
57 const UpdateCallback& callback) = 0;
58
59 // Asynchronously removes requests from the store using their IDs.
60 // Result of the update, and a number of removed pages is passed in the
61 // callback.
62 // Result of remove should be false, when one of the provided items couldn't
63 // be deleted, e.g. because it was missing.
64 virtual void RemoveRequests(const std::vector<int64_t>& request_ids,
65 const UpdateCallback& callback) = 0;
66
67 // Resets the store (removes any existing data).
68 virtual void Reset(const ResetCallback& callback) = 0;
69
70 // Gets the store state.
71 virtual StoreState state() const = 0;
72 };
73
74 } // namespace offline_pages
75
76 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698