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

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

Issue 2228813003: Changes to fit better with the needs of the download manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use typedef to hide an ugly type. Created 4 years, 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "components/offline_pages/offline_page_item.h" 12 #include "components/offline_pages/background/request_queue.h"
13 13
14 namespace offline_pages { 14 namespace offline_pages {
15 15
16 class SavePageRequest; 16 class SavePageRequest;
17 17
18 // Interface for classes storing save page requests. 18 // Interface for classes storing save page requests.
19 class RequestQueueStore { 19 class RequestQueueStore {
20 public: 20 public:
21 enum class UpdateStatus { 21 enum class UpdateStatus {
22 ADDED, // Request was added successfully. 22 ADDED, // Request was added successfully.
23 UPDATED, // Request was updated successfully. 23 UPDATED, // Request was updated successfully.
24 FAILED, // Add or update attempt failed. 24 FAILED, // Add or update attempt failed.
25 }; 25 };
26 26
27 typedef base::Callback<void( 27 typedef base::Callback<void(
28 bool /* success */, 28 bool /* success */,
29 const std::vector<SavePageRequest>& /* requests */)> 29 const std::vector<SavePageRequest>& /* requests */)>
30 GetRequestsCallback; 30 GetRequestsCallback;
31 typedef base::Callback<void(UpdateStatus)> UpdateCallback; 31 typedef base::Callback<void(UpdateStatus)> UpdateCallback;
32 typedef base::Callback<void(bool /* success */, 32 typedef base::Callback<void(
33 int /* number of deleted requests */)> 33 const RequestQueue::UpdateMultipleRequestResults&)>
34 RemoveCallback; 34 RemoveCallback;
35 typedef base::Callback<void(bool /* success */)> ResetCallback; 35 typedef base::Callback<void(bool /* success */)> ResetCallback;
36 36
37 virtual ~RequestQueueStore(){}; 37 virtual ~RequestQueueStore(){};
38 38
39 // Gets all of the requests from the store. 39 // Gets all of the requests from the store.
40 virtual void GetRequests(const GetRequestsCallback& callback) = 0; 40 virtual void GetRequests(const GetRequestsCallback& callback) = 0;
41 41
42 // Asynchronously adds or updates request in store. 42 // Asynchronously adds or updates request in store.
43 // Result of the update is passed in the callback. 43 // Result of the update is passed in the callback.
44 virtual void AddOrUpdateRequest(const SavePageRequest& request, 44 virtual void AddOrUpdateRequest(const SavePageRequest& request,
45 const UpdateCallback& callback) = 0; 45 const UpdateCallback& callback) = 0;
46 46
47 // Asynchronously removes requests from the store using their IDs. 47 // Asynchronously removes requests from the store using their IDs.
48 // Result of the update, and a number of removed pages is passed in the 48 // Result of the update, and a number of removed pages is passed in the
49 // callback. 49 // callback.
50 // Result of remove should be false, when one of the provided items couldn't 50 // Result of remove should be false, when one of the provided items couldn't
51 // be deleted, e.g. because it was missing. 51 // be deleted, e.g. because it was missing.
52 virtual void RemoveRequests(const std::vector<int64_t>& request_ids, 52 virtual void RemoveRequests(const std::vector<int64_t>& request_ids,
53 const RemoveCallback& callback) = 0; 53 const RemoveCallback& callback) = 0;
54 54
55 // Asynchronously removes requests from the store using their ClientIds.
56 // Result of the update, and a number of removed pages is passed in the
57 // callback. Result of remove should be false, when one of the provided items
58 // couldn't be deleted, e.g. because it was missing. In case client_ids is
59 // empty, though this will return true, but the count of deleted pages will be
60 // 0.
61 virtual void RemoveRequestsByClientId(const std::vector<ClientId>& client_ids,
62 const RemoveCallback& callback) = 0;
63
64 // Resets the store. 55 // Resets the store.
65 virtual void Reset(const ResetCallback& callback) = 0; 56 virtual void Reset(const ResetCallback& callback) = 0;
66 }; 57 };
67 58
68 } // namespace offline_pages 59 } // namespace offline_pages
69 60
70 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ 61 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698