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

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

Issue 2256373002: Adds request queue removal capability to OfflinePageBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@query-queue
Patch Set: Rebase. Created 4 years, 3 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_COORDINATOR_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 std::unique_ptr<RequestQueue> queue, 58 std::unique_ptr<RequestQueue> queue,
59 std::unique_ptr<Scheduler> scheduler); 59 std::unique_ptr<Scheduler> scheduler);
60 60
61 ~RequestCoordinator() override; 61 ~RequestCoordinator() override;
62 62
63 // Queues |request| to later load and save when system conditions allow. 63 // Queues |request| to later load and save when system conditions allow.
64 // Returns true if the page could be queued successfully. 64 // Returns true if the page could be queued successfully.
65 bool SavePageLater( 65 bool SavePageLater(
66 const GURL& url, const ClientId& client_id, bool user_reqeusted); 66 const GURL& url, const ClientId& client_id, bool user_reqeusted);
67 67
68 // Callback specifying which request IDs were actually removed.
69 typedef base::Callback<void(
70 const RequestQueue::UpdateMultipleRequestResults&)>
71 RemoveRequestsCallback;
72
68 // Remove a list of requests by |request_id|. This removes requests from the 73 // Remove a list of requests by |request_id|. This removes requests from the
69 // request queue, but does not cancel an in-progress pre-render. 74 // request queue, but does not cancel an in-progress pre-render.
70 // TODO(petewil): Add code to cancel an in-progress pre-render. 75 // TODO(petewil): Add code to cancel an in-progress pre-render.
71 void RemoveRequests(const std::vector<int64_t>& request_ids); 76 void RemoveRequests(const std::vector<int64_t>& request_ids,
77 const RemoveRequestsCallback& callback);
72 78
73 // Pause a list of requests by |request_id|. This will change the state 79 // Pause a list of requests by |request_id|. This will change the state
74 // in the request queue so the request cannot be started. 80 // in the request queue so the request cannot be started.
75 // TODO(petewil): Add code to cancel an in-progress pre-render. 81 // TODO(petewil): Add code to cancel an in-progress pre-render.
76 void PauseRequests(const std::vector<int64_t>& request_ids); 82 void PauseRequests(const std::vector<int64_t>& request_ids);
77 83
78 // Resume a list of previously paused requests, making them available. 84 // Resume a list of previously paused requests, making them available.
79 void ResumeRequests(const std::vector<int64_t>& request_ids); 85 void ResumeRequests(const std::vector<int64_t>& request_ids);
80 86
81 // Callback that receives the response for GetAllRequests. Client must 87 // Callback that receives the response for GetAllRequests. Client must
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const SavePageRequest& request); 163 const SavePageRequest& request);
158 164
159 // Receives the result of update and delete requests to the request queue. 165 // Receives the result of update and delete requests to the request queue.
160 void UpdateRequestCallback(const ClientId& client_id, 166 void UpdateRequestCallback(const ClientId& client_id,
161 RequestQueue::UpdateRequestResult result); 167 RequestQueue::UpdateRequestResult result);
162 168
163 void UpdateMultipleRequestsCallback( 169 void UpdateMultipleRequestsCallback(
164 const RequestQueue::UpdateMultipleRequestResults& result, 170 const RequestQueue::UpdateMultipleRequestResults& result,
165 const std::vector<SavePageRequest>& requests); 171 const std::vector<SavePageRequest>& requests);
166 172
167 void RemoveRequestsCallback( 173 void HandleRemovedRequestsAndCallback(
174 const RemoveRequestsCallback& callback,
168 const RequestQueue::UpdateMultipleRequestResults& results, 175 const RequestQueue::UpdateMultipleRequestResults& results,
169 const std::vector<SavePageRequest>& requests); 176 const std::vector<SavePageRequest>& requests);
170 177
178 void HandleRemovedRequests(
179 const RequestQueue::UpdateMultipleRequestResults& results,
180 const std::vector<SavePageRequest>& requests);
181
171 // Callback from the request picker when it has chosen our next request. 182 // Callback from the request picker when it has chosen our next request.
172 void RequestPicked(const SavePageRequest& request); 183 void RequestPicked(const SavePageRequest& request);
173 184
174 // Callback from the request picker when no more requests are in the queue. 185 // Callback from the request picker when no more requests are in the queue.
175 void RequestQueueEmpty(); 186 void RequestQueueEmpty();
176 187
177 // Cancels an in progress pre-rendering, and updates state appropriately. 188 // Cancels an in progress pre-rendering, and updates state appropriately.
178 void StopPrerendering(); 189 void StopPrerendering();
179 190
180 void SendRequestToOffliner(const SavePageRequest& request); 191 void SendRequestToOffliner(const SavePageRequest& request);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 base::TimeDelta offliner_timeout_; 251 base::TimeDelta offliner_timeout_;
241 // Allows us to pass a weak pointer to callbacks. 252 // Allows us to pass a weak pointer to callbacks.
242 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 253 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
243 254
244 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 255 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
245 }; 256 };
246 257
247 } // namespace offline_pages 258 } // namespace offline_pages
248 259
249 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 260 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/BUILD.gn ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698