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

Side by Side Diff: components/offline_pages/background/request_picker.cc

Issue 2332923003: Fix post submit problems for the vector of smart pointers change. (Closed)
Patch Set: Merge with request picker changes. 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
« no previous file with comments | « no previous file | no next file » | 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 #include "components/offline_pages/background/request_picker.h" 5 #include "components/offline_pages/background/request_picker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "components/offline_pages/background/save_page_request.h" 9 #include "components/offline_pages/background/save_page_request.h"
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (earlier_requests_better_) 235 if (earlier_requests_better_)
236 result *= -1; 236 result *= -1;
237 237
238 return result; 238 return result;
239 } 239 }
240 240
241 void RequestPicker::SplitRequests( 241 void RequestPicker::SplitRequests(
242 std::vector<std::unique_ptr<SavePageRequest>> requests, 242 std::vector<std::unique_ptr<SavePageRequest>> requests,
243 std::vector<std::unique_ptr<SavePageRequest>>* valid_requests, 243 std::vector<std::unique_ptr<SavePageRequest>>* valid_requests,
244 std::vector<std::unique_ptr<SavePageRequest>>* expired_requests) { 244 std::vector<std::unique_ptr<SavePageRequest>>* expired_requests) {
245 std::vector<std::unique_ptr<SavePageRequest>>::iterator request;
246 for (auto& request : requests) { 245 for (auto& request : requests) {
247 if (base::Time::Now() - request->creation_time() >= 246 if (base::Time::Now() - request->creation_time() >=
248 base::TimeDelta::FromSeconds(kRequestExpirationTimeInSeconds)) { 247 base::TimeDelta::FromSeconds(kRequestExpirationTimeInSeconds)) {
249 expired_requests->push_back(std::move(request)); 248 expired_requests->push_back(std::move(request));
250 } else { 249 } else {
251 valid_requests->push_back(std::move(request)); 250 valid_requests->push_back(std::move(request));
252 } 251 }
253 } 252 }
254 } 253 }
255 254
256 // Callback used after expired requests are deleted from the queue and notifies 255 // Callback used after expired requests are deleted from the queue and notifies
257 // the coordinator. 256 // the coordinator.
258 void RequestPicker::OnRequestExpired( 257 void RequestPicker::OnRequestExpired(
259 const RequestQueue::UpdateMultipleRequestResults& results, 258 const RequestQueue::UpdateMultipleRequestResults& results,
260 const std::vector<std::unique_ptr<SavePageRequest>> requests) { 259 const std::vector<std::unique_ptr<SavePageRequest>> requests) {
261 std::vector<std::unique_ptr<SavePageRequest>>::const_iterator request; 260 for (const auto& request : requests) {
262 for (request = requests.begin(); request != requests.end(); ++request) {
263 const RequestCoordinator::BackgroundSavePageResult result( 261 const RequestCoordinator::BackgroundSavePageResult result(
264 RequestCoordinator::BackgroundSavePageResult::EXPIRED); 262 RequestCoordinator::BackgroundSavePageResult::EXPIRED);
265 event_logger_->RecordDroppedSavePageRequest( 263 event_logger_->RecordDroppedSavePageRequest(
266 request->get()->client_id().name_space, result, 264 request->client_id().name_space, result,
267 request->get()->request_id()); 265 request->request_id());
268 notifier_->NotifyCompleted(*(request->get()), result); 266 notifier_->NotifyCompleted(*request, result);
269 } 267 }
270 } 268 }
271 269
272 } // namespace offline_pages 270 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698