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

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

Issue 2202113002: API to provide status of save page reqeusts to API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up naming 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
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Queues |request| to later load and save when system conditions allow. 48 // Queues |request| to later load and save when system conditions allow.
49 // Returns true if the page could be queued successfully. 49 // Returns true if the page could be queued successfully.
50 bool SavePageLater( 50 bool SavePageLater(
51 const GURL& url, const ClientId& client_id, bool user_reqeusted); 51 const GURL& url, const ClientId& client_id, bool user_reqeusted);
52 52
53 // Remove a list of requests by |client_id|. This removes requests from the 53 // Remove a list of requests by |client_id|. This removes requests from the
54 // request queue, but does not cancel an in-progress pre-render. 54 // request queue, but does not cancel an in-progress pre-render.
55 // TODO(petewil): Add code to cancel an in-progress pre-render. 55 // TODO(petewil): Add code to cancel an in-progress pre-render.
56 void RemoveRequests(const std::vector<ClientId>& client_ids); 56 void RemoveRequests(const std::vector<ClientId>& client_ids);
57 57
58 // Callback that receives the response for GetQueuedRequests. Client must
59 // copy the result right away, it goes out of scope at the end of the
60 // callback.
61 typedef base::Callback<void(const std::vector<ClientId>&)>
62 QueuedRequestCallback;
63
64 // For a client namespace, get the ClientId of all requests for that
65 // namespace.
66 void GetQueuedRequests(const std::string& client_namespace,
67 const QueuedRequestCallback& callback);
68
58 // Starts processing of one or more queued save page later requests. 69 // Starts processing of one or more queued save page later requests.
59 // Returns whether processing was started and that caller should expect 70 // Returns whether processing was started and that caller should expect
60 // a callback. If processing was already active, returns false. 71 // a callback. If processing was already active, returns false.
61 bool StartProcessing(const DeviceConditions& device_conditions, 72 bool StartProcessing(const DeviceConditions& device_conditions,
62 const base::Callback<void(bool)>& callback); 73 const base::Callback<void(bool)>& callback);
63 74
64 // Stops the current request processing if active. This is a way for 75 // Stops the current request processing if active. This is a way for
65 // caller to abort processing; otherwise, processing will complete on 76 // caller to abort processing; otherwise, processing will complete on
66 // its own. In either case, the callback will be called when processing 77 // its own. In either case, the callback will be called when processing
67 // is stopped or complete. 78 // is stopped or complete.
(...skipping 25 matching lines...) Expand all
93 // the next StartProcessing() call. 104 // the next StartProcessing() call.
94 bool is_canceled() { 105 bool is_canceled() {
95 return is_canceled_; 106 return is_canceled_;
96 } 107 }
97 108
98 OfflineEventLogger* GetLogger() { 109 OfflineEventLogger* GetLogger() {
99 return &event_logger_; 110 return &event_logger_;
100 } 111 }
101 112
102 private: 113 private:
114 // Receives the results of a get from the request queue, and turns that into
115 // ClientId objects for the caller of GetQueuedRequests.
116 void GetQueuedRequestsCallback(const std::string& client_namespace,
117 const QueuedRequestCallback& callback,
118 RequestQueue::GetRequestsResult result,
119 const std::vector<SavePageRequest>& requests);
120
121 // Receives the result of add requests to the request queue.
103 void AddRequestResultCallback(RequestQueue::AddRequestResult result, 122 void AddRequestResultCallback(RequestQueue::AddRequestResult result,
104 const SavePageRequest& request); 123 const SavePageRequest& request);
105 124
125 // Receives the result of update and delete requests to the request queue.
106 void UpdateRequestCallback(RequestQueue::UpdateRequestResult result); 126 void UpdateRequestCallback(RequestQueue::UpdateRequestResult result);
107 127
108 // Callback from the request picker when it has chosen our next request. 128 // Callback from the request picker when it has chosen our next request.
109 void RequestPicked(const SavePageRequest& request); 129 void RequestPicked(const SavePageRequest& request);
110 130
111 // Callback from the request picker when no more requests are in the queue. 131 // Callback from the request picker when no more requests are in the queue.
112 void RequestQueueEmpty(); 132 void RequestQueueEmpty();
113 133
114 void SendRequestToOffliner(const SavePageRequest& request); 134 void SendRequestToOffliner(const SavePageRequest& request);
115 135
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 base::TimeDelta offliner_timeout_; 187 base::TimeDelta offliner_timeout_;
168 // Allows us to pass a weak pointer to callbacks. 188 // Allows us to pass a weak pointer to callbacks.
169 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 189 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
170 190
171 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 191 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
172 }; 192 };
173 193
174 } // namespace offline_pages 194 } // namespace offline_pages
175 195
176 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 196 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698