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

Side by Side Diff: components/offline_pages/background/request_coordinator.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
« 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 std::unique_ptr<RequestQueue> queue, 43 std::unique_ptr<RequestQueue> queue,
44 std::unique_ptr<Scheduler> scheduler); 44 std::unique_ptr<Scheduler> scheduler);
45 45
46 ~RequestCoordinator() override; 46 ~RequestCoordinator() override;
47 47
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 |request_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<int64_t>& request_ids);
57 57
58 // Callback that receives the response for GetQueuedRequests. Client must 58 // Callback that receives the response for GetRequests. Client must
59 // copy the result right away, it goes out of scope at the end of the 59 // copy the result right away, it goes out of scope at the end of the
60 // callback. 60 // callback.
61 typedef base::Callback<void(const std::vector<ClientId>&)> 61 typedef base::Callback<void(const std::vector<SavePageRequest>&)>
62 QueuedRequestCallback; 62 GetRequestsCallback;
63 63
64 // For a client namespace, get the ClientId of all requests for that 64 // Get all save page request items in the callback.
65 // namespace. 65 void GetAllRequests(const GetRequestsCallback& callback);
66 void GetQueuedRequests(const std::string& client_namespace,
67 const QueuedRequestCallback& callback);
68 66
69 // Starts processing of one or more queued save page later requests. 67 // Starts processing of one or more queued save page later requests.
70 // Returns whether processing was started and that caller should expect 68 // Returns whether processing was started and that caller should expect
71 // a callback. If processing was already active, returns false. 69 // a callback. If processing was already active, returns false.
72 bool StartProcessing(const DeviceConditions& device_conditions, 70 bool StartProcessing(const DeviceConditions& device_conditions,
73 const base::Callback<void(bool)>& callback); 71 const base::Callback<void(bool)>& callback);
74 72
75 // Stops the current request processing if active. This is a way for 73 // Stops the current request processing if active. This is a way for
76 // caller to abort processing; otherwise, processing will complete on 74 // caller to abort processing; otherwise, processing will complete on
77 // its own. In either case, the callback will be called when processing 75 // its own. In either case, the callback will be called when processing
(...skipping 27 matching lines...) Expand all
105 bool is_canceled() { 103 bool is_canceled() {
106 return is_canceled_; 104 return is_canceled_;
107 } 105 }
108 106
109 OfflineEventLogger* GetLogger() { 107 OfflineEventLogger* GetLogger() {
110 return &event_logger_; 108 return &event_logger_;
111 } 109 }
112 110
113 private: 111 private:
114 // Receives the results of a get from the request queue, and turns that into 112 // Receives the results of a get from the request queue, and turns that into
115 // ClientId objects for the caller of GetQueuedRequests. 113 // SavePageRequest objects for the caller of GetQueuedRequests.
116 void GetQueuedRequestsCallback(const std::string& client_namespace, 114 void GetQueuedRequestsCallback(const GetRequestsCallback& callback,
117 const QueuedRequestCallback& callback,
118 RequestQueue::GetRequestsResult result, 115 RequestQueue::GetRequestsResult result,
119 const std::vector<SavePageRequest>& requests); 116 const std::vector<SavePageRequest>& requests);
120 117
121 // Receives the result of add requests to the request queue. 118 // Receives the result of add requests to the request queue.
122 void AddRequestResultCallback(RequestQueue::AddRequestResult result, 119 void AddRequestResultCallback(RequestQueue::AddRequestResult result,
123 const SavePageRequest& request); 120 const SavePageRequest& request);
124 121
125 // Receives the result of update and delete requests to the request queue. 122 // Receives the result of update and delete requests to the request queue.
126 void UpdateRequestCallback(const ClientId& client_id, 123 void UpdateRequestCallback(const ClientId& client_id,
127 RequestQueue::UpdateRequestResult result); 124 RequestQueue::UpdateRequestResult result);
128 125
129 void UpdateMultipleRequestCallback(RequestQueue::UpdateRequestResult result); 126 void UpdateMultipleRequestCallback(RequestQueue::UpdateRequestResult result);
130 127
128 void RemoveRequestsCallback(
129 const RequestQueue::UpdateMultipleRequestResults& results);
130
131 // Callback from the request picker when it has chosen our next request. 131 // Callback from the request picker when it has chosen our next request.
132 void RequestPicked(const SavePageRequest& request); 132 void RequestPicked(const SavePageRequest& request);
133 133
134 // Callback from the request picker when no more requests are in the queue. 134 // Callback from the request picker when no more requests are in the queue.
135 void RequestQueueEmpty(); 135 void RequestQueueEmpty();
136 136
137 void SendRequestToOffliner(const SavePageRequest& request); 137 void SendRequestToOffliner(const SavePageRequest& request);
138 138
139 // Called by the offliner when an offlining request is completed. (and by 139 // Called by the offliner when an offlining request is completed. (and by
140 // tests). 140 // tests).
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 base::TimeDelta offliner_timeout_; 192 base::TimeDelta offliner_timeout_;
193 // Allows us to pass a weak pointer to callbacks. 193 // Allows us to pass a weak pointer to callbacks.
194 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 194 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
195 195
196 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 196 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
197 }; 197 };
198 198
199 } // namespace offline_pages 199 } // namespace offline_pages
200 200
201 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 201 #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