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

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

Issue 2233493003: [Offline Pages] Remove expired requests from the queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging. 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_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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 // Observers implementing the RequestCoordinator::Observer interface can 123 // Observers implementing the RequestCoordinator::Observer interface can
124 // register here to get notifications of changes to request state. This 124 // register here to get notifications of changes to request state. This
125 // pointer is not owned, and it is the callers responsibility to remove the 125 // pointer is not owned, and it is the callers responsibility to remove the
126 // observer before the observer is deleted. 126 // observer before the observer is deleted.
127 void AddObserver(RequestCoordinator::Observer* observer); 127 void AddObserver(RequestCoordinator::Observer* observer);
128 128
129 void RemoveObserver(RequestCoordinator::Observer* observer); 129 void RemoveObserver(RequestCoordinator::Observer* observer);
130 130
131 // Send a notification of the |request| to observers via coordinator.
132 void NotifyAdded(const SavePageRequest& request);
133 void NotifySucceeded(const SavePageRequest& request);
134 virtual void NotifyFailed(const SavePageRequest& request,
135 SavePageStatus status);
136 void NotifyChanged(const SavePageRequest& request);
137 void NotifyRemoved(const SavePageRequest& request);
Pete Williamson 2016/08/16 23:40:46 FYI: You'll need to do another merge soon, these a
romax 2016/08/17 20:07:58 Done.
138
131 // Returns the request queue used for requests. Coordinator keeps ownership. 139 // Returns the request queue used for requests. Coordinator keeps ownership.
132 RequestQueue* queue() { return queue_.get(); } 140 RequestQueue* queue() { return queue_.get(); }
133 141
134 // Return an unowned pointer to the Scheduler. 142 // Return an unowned pointer to the Scheduler.
135 Scheduler* scheduler() { return scheduler_.get(); } 143 Scheduler* scheduler() { return scheduler_.get(); }
136 144
137 // Returns the status of the most recent offlining. 145 // Returns the status of the most recent offlining.
138 Offliner::RequestStatus last_offlining_status() { 146 Offliner::RequestStatus last_offlining_status() {
139 return last_offlining_status_; 147 return last_offlining_status_;
140 } 148 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 192
185 void SendRequestToOffliner(const SavePageRequest& request); 193 void SendRequestToOffliner(const SavePageRequest& request);
186 194
187 // Called by the offliner when an offlining request is completed. (and by 195 // Called by the offliner when an offlining request is completed. (and by
188 // tests). 196 // tests).
189 void OfflinerDoneCallback(const SavePageRequest& request, 197 void OfflinerDoneCallback(const SavePageRequest& request,
190 Offliner::RequestStatus status); 198 Offliner::RequestStatus status);
191 199
192 void TryNextRequest(); 200 void TryNextRequest();
193 201
194 void NotifyAdded(const SavePageRequest& request);
195 void NotifySucceeded(const SavePageRequest& request);
196 void NotifyFailed(const SavePageRequest& request, SavePageStatus status);
197 void NotifyChanged(const SavePageRequest& request);
198 void NotifyRemoved(const SavePageRequest& request);
199
200 // Returns the appropriate offliner to use, getting a new one from the factory 202 // Returns the appropriate offliner to use, getting a new one from the factory
201 // if needed. 203 // if needed.
202 void GetOffliner(); 204 void GetOffliner();
203 205
204 void SetOfflinerTimeoutForTest(const base::TimeDelta& timeout) { 206 void SetOfflinerTimeoutForTest(const base::TimeDelta& timeout) {
205 offliner_timeout_ = timeout; 207 offliner_timeout_ = timeout;
206 } 208 }
207 209
208 void SetDeviceConditionsForTest(DeviceConditions& current_conditions) { 210 void SetDeviceConditionsForTest(DeviceConditions& current_conditions) {
209 current_conditions_.reset(new DeviceConditions(current_conditions)); 211 current_conditions_.reset(new DeviceConditions(current_conditions));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 base::TimeDelta offliner_timeout_; 250 base::TimeDelta offliner_timeout_;
249 // Allows us to pass a weak pointer to callbacks. 251 // Allows us to pass a weak pointer to callbacks.
250 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 252 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
251 253
252 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 254 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
253 }; 255 };
254 256
255 } // namespace offline_pages 257 } // namespace offline_pages
256 258
257 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 259 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698