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

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

Issue 2218403002: Change database scheme - add state and start tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop clearing last request time 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 #include "components/offline_pages/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // TODO(dougarnett): See if we can conclusively identify other attempt 274 // TODO(dougarnett): See if we can conclusively identify other attempt
275 // aborted cases to treat this way (eg, for Render Process Killed). 275 // aborted cases to treat this way (eg, for Render Process Killed).
276 SavePageRequest updated_request(request); 276 SavePageRequest updated_request(request);
277 updated_request.MarkAttemptAborted(); 277 updated_request.MarkAttemptAborted();
278 queue_->UpdateRequest(updated_request, 278 queue_->UpdateRequest(updated_request,
279 base::Bind(&RequestCoordinator::UpdateRequestCallback, 279 base::Bind(&RequestCoordinator::UpdateRequestCallback,
280 weak_ptr_factory_.GetWeakPtr(), 280 weak_ptr_factory_.GetWeakPtr(),
281 updated_request.client_id())); 281 updated_request.client_id()));
282 282
283 } else if (status == Offliner::RequestStatus::SAVED || 283 } else if (status == Offliner::RequestStatus::SAVED ||
284 request.attempt_count() >= policy_->GetMaxTries()) { 284 request.completed_attempt_count() + 1 >=
285 policy_->GetMaxCompletedTries()) {
285 // Remove the request from the queue if it either succeeded or exceeded the 286 // Remove the request from the queue if it either succeeded or exceeded the
286 // max number of retries. 287 // max number of retries. The +1 represents the request that just
288 // completed. Since we call MarkAttemptCompleted within the if branches,
289 // the completed_attempt_count has not yet been updated when we are checking
290 // the if condition.
287 queue_->RemoveRequest( 291 queue_->RemoveRequest(
288 request.request_id(), 292 request.request_id(),
289 base::Bind(&RequestCoordinator::UpdateRequestCallback, 293 base::Bind(&RequestCoordinator::UpdateRequestCallback,
290 weak_ptr_factory_.GetWeakPtr(), request.client_id())); 294 weak_ptr_factory_.GetWeakPtr(), request.client_id()));
291 } else { 295 } else {
292 // If we failed, but are not over the limit, update the request in the 296 // If we failed, but are not over the limit, update the request in the
293 // queue. 297 // queue.
294 SavePageRequest updated_request(request); 298 SavePageRequest updated_request(request);
295 updated_request.MarkAttemptCompleted(); 299 updated_request.MarkAttemptCompleted();
296 queue_->UpdateRequest(updated_request, 300 queue_->UpdateRequest(updated_request,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 return trigger_conditions; 336 return trigger_conditions;
333 } 337 }
334 338
335 void RequestCoordinator::GetOffliner() { 339 void RequestCoordinator::GetOffliner() {
336 if (!offliner_) { 340 if (!offliner_) {
337 offliner_ = factory_->GetOffliner(policy_.get()); 341 offliner_ = factory_->GetOffliner(policy_.get());
338 } 342 }
339 } 343 }
340 344
341 } // namespace offline_pages 345 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698