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

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

Issue 2221323003: Add an API to Pause and Resume background offlining requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test break introduced by merge 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/background/request_queue.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_page_item.h"
13 15
14 namespace offline_pages { 16 namespace offline_pages {
15 17
16 class SavePageRequest;
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 // TODO(petewil): What if no items were updated? Maybe this should work more
27 // like DeleteCallback, passing pairs of request_id and status.
26 28
27 typedef base::Callback<void( 29 typedef base::Callback<void(
28 bool /* success */, 30 bool /* success */,
29 const std::vector<SavePageRequest>& /* requests */)> 31 const std::vector<SavePageRequest>& /* requests */)>
30 GetRequestsCallback; 32 GetRequestsCallback;
31 typedef base::Callback<void(UpdateStatus)> UpdateCallback; 33 typedef base::Callback<void(UpdateStatus)> UpdateCallback;
32 typedef base::Callback<void( 34 typedef base::Callback<void(
33 const RequestQueue::UpdateMultipleRequestResults&)> 35 const RequestQueue::UpdateMultipleRequestResults&)>
34 RemoveCallback; 36 RemoveCallback;
35 typedef base::Callback<void(bool /* success */)> ResetCallback; 37 typedef base::Callback<void(bool /* success */)> ResetCallback;
36 38
37 virtual ~RequestQueueStore(){}; 39 virtual ~RequestQueueStore(){};
38 40
39 // Gets all of the requests from the store. 41 // Gets all of the requests from the store.
40 virtual void GetRequests(const GetRequestsCallback& callback) = 0; 42 virtual void GetRequests(const GetRequestsCallback& callback) = 0;
41 43
42 // Asynchronously adds or updates request in store. 44 // Asynchronously adds or updates request in store.
43 // Result of the update is passed in the callback. 45 // Result of the update is passed in the callback.
44 virtual void AddOrUpdateRequest(const SavePageRequest& request, 46 virtual void AddOrUpdateRequest(const SavePageRequest& request,
45 const UpdateCallback& callback) = 0; 47 const UpdateCallback& callback) = 0;
46 48
47 // Asynchronously removes requests from the store using their IDs. 49 // Asynchronously removes requests from the store using their IDs.
48 // Result of the update, and a number of removed pages is passed in the 50 // Result of the update, and a number of removed pages is passed in the
49 // callback. 51 // callback.
50 // Result of remove should be false, when one of the provided items couldn't 52 // Result of remove should be false, when one of the provided items couldn't
51 // be deleted, e.g. because it was missing. 53 // be deleted, e.g. because it was missing.
52 virtual void RemoveRequests(const std::vector<int64_t>& request_ids, 54 virtual void RemoveRequests(const std::vector<int64_t>& request_ids,
53 const RemoveCallback& callback) = 0; 55 const RemoveCallback& callback) = 0;
54 56
57 // Asynchronously changes the state of requests from the store using their
58 // request id.
59 virtual void ChangeRequestsState(
60 const std::vector<int64_t>& request_ids,
61 const SavePageRequest::RequestState new_state,
62 const UpdateCallback& callback) = 0;
63
55 // Resets the store. 64 // Resets the store.
56 virtual void Reset(const ResetCallback& callback) = 0; 65 virtual void Reset(const ResetCallback& callback) = 0;
57 }; 66 };
58 67
59 } // namespace offline_pages 68 } // namespace offline_pages
60 69
61 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ 70 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698