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

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

Issue 1951483002: [Offline pages] Adding in memory request queue store with tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Udpating name of variable to make code more readable Created 4 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 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
13 namespace offline_pages {
14
15 class SavePageRequest;
16
17 // Interface for classes storing save page requests.
18 class RequestQueueStore {
19 public:
20 enum class UpdateStatus {
21 kAdded, // Request was added successfully.
22 kUpdated, // Request was updated successfully.
23 kFailed, // Add or update attempt failed.
24 };
25
26 typedef base::Callback<void(
27 bool /* success */,
28 const std::vector<SavePageRequest>& /* requests */)>
29 GetRequestsCallback;
30 typedef base::Callback<void(UpdateStatus)> UpdateCallback;
31 typedef base::Callback<void(bool /* success */,
32 int /* number of deleted requests */)>
33 RemoveCallback;
34 typedef base::Callback<void(bool /* success */)> ResetCallback;
35
36 virtual ~RequestQueueStore(){};
37
38 // Gets all of the requests from the store.
39 virtual void GetRequests(const GetRequestsCallback& callback) = 0;
40
41 // Asynchronously adds or updates request in store.
42 // Result of the update is passed in the callback.
43 virtual void AddOrUpdateRequest(const SavePageRequest& request,
44 const UpdateCallback& callback) = 0;
45
46 // Asynchronously removes requests from the store using their IDs.
47 // Result of the update, and a number of removed pages is passed in the
48 // callback.
49 // Result of remove should be false, when one of the provided items couldn't
50 // be deleted, e.g. because it was missing.
51 virtual void RemoveRequests(const std::vector<int64_t>& request_ids,
52 const RemoveCallback& callback) = 0;
53
54 // Resets the store.
55 virtual void Reset(const ResetCallback& callback) = 0;
56 };
57
58 } // namespace offline_pages
59
60 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698