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

Side by Side Diff: components/offline_pages/background/request_queue.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: Switch to request ID as key 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_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Removes the request matching the |request_id|. Result is returned through 77 // Removes the request matching the |request_id|. Result is returned through
78 // |callback|. 78 // |callback|.
79 void RemoveRequest(int64_t request_id, const UpdateRequestCallback& callback); 79 void RemoveRequest(int64_t request_id, const UpdateRequestCallback& callback);
80 80
81 // Removes the requests matching the |client_ids|. Results are returned 81 // Removes the requests matching the |client_ids|. Results are returned
82 // through |callback|. 82 // through |callback|.
83 void RemoveRequestsByClientId(const std::vector<ClientId>& client_id, 83 void RemoveRequestsByClientId(const std::vector<ClientId>& client_id,
84 const UpdateRequestCallback& callback); 84 const UpdateRequestCallback& callback);
85 85
86 // Pauses the requests matching the |request_ids|. Results are returned
87 // through |callback|.
88 void PauseRequests(const std::vector<int64_t>& request_ids,
89 const UpdateRequestCallback& callback);
90
91 // Resumes the requests matching the |request_ids|. Results are returned
92 // through |callback|.
93 void ResumeRequests(const std::vector<int64_t>& request_ids,
94 const UpdateRequestCallback& callback);
95
86 void GetForUpdateDone( 96 void GetForUpdateDone(
87 const RequestQueue::UpdateRequestCallback& update_callback, 97 const RequestQueue::UpdateRequestCallback& update_callback,
88 const SavePageRequest& update_request, 98 const SavePageRequest& update_request,
89 bool success, 99 bool success,
90 const std::vector<SavePageRequest>& requests); 100 const std::vector<SavePageRequest>& requests);
91 101
92 private: 102 private:
93 // Callback used by |PurgeRequests|. 103 // Callback used by |PurgeRequests|.
94 typedef base::Callback<void(UpdateRequestResult, 104 typedef base::Callback<void(UpdateRequestResult,
95 int /* removed requests count */)> 105 int /* removed requests count */)>
96 PurgeRequestsCallback; 106 PurgeRequestsCallback;
97 107
98 // Purges the queue, removing the requests that are no longer relevant, e.g. 108 // Purges the queue, removing the requests that are no longer relevant, e.g.
99 // expired request. Result is returned through |callback| carries the number 109 // expired request. Result is returned through |callback| carries the number
100 // of removed requests. 110 // of removed requests.
101 void PurgeRequests(const PurgeRequestsCallback& callback); 111 void PurgeRequests(const PurgeRequestsCallback& callback);
102 112
103 std::unique_ptr<RequestQueueStore> store_; 113 std::unique_ptr<RequestQueueStore> store_;
104 114
105 // Allows us to pass a weak pointer to callbacks. 115 // Allows us to pass a weak pointer to callbacks.
106 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; 116 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_;
107 117
108 DISALLOW_COPY_AND_ASSIGN(RequestQueue); 118 DISALLOW_COPY_AND_ASSIGN(RequestQueue);
109 }; 119 };
110 120
111 } // namespace offline_pages 121 } // namespace offline_pages
112 122
113 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ 123 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698