| OLD | NEW |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 RecordOfflinerResultUMA(last_offlining_status_); | 202 RecordOfflinerResultUMA(last_offlining_status_); |
| 203 watchdog_timer_.Stop(); | 203 watchdog_timer_.Stop(); |
| 204 | 204 |
| 205 is_busy_ = false; | 205 is_busy_ = false; |
| 206 | 206 |
| 207 int64_t new_attempt_count = request.attempt_count() + 1; | 207 int64_t new_attempt_count = request.attempt_count() + 1; |
| 208 | 208 |
| 209 // Remove the request from the queue if it either succeeded or exceeded the | 209 // Remove the request from the queue if it either succeeded or exceeded the |
| 210 // max number of retries. | 210 // max number of retries. |
| 211 if (status == Offliner::RequestStatus::SAVED | 211 if (status == Offliner::RequestStatus::SAVED |
| 212 || new_attempt_count > policy_->GetMaxRetries()) { | 212 || new_attempt_count > policy_->GetMaxTries()) { |
| 213 queue_->RemoveRequest(request.request_id(), | 213 queue_->RemoveRequest(request.request_id(), |
| 214 base::Bind(&RequestCoordinator::UpdateRequestCallback, | 214 base::Bind(&RequestCoordinator::UpdateRequestCallback, |
| 215 weak_ptr_factory_.GetWeakPtr())); | 215 weak_ptr_factory_.GetWeakPtr())); |
| 216 } else { | 216 } else { |
| 217 // If we failed, but are not over the limit, update the request in the | 217 // If we failed, but are not over the limit, update the request in the |
| 218 // queue. | 218 // queue. |
| 219 SavePageRequest updated_request(request); | 219 SavePageRequest updated_request(request); |
| 220 updated_request.set_attempt_count(new_attempt_count); | 220 updated_request.set_attempt_count(new_attempt_count); |
| 221 updated_request.set_last_attempt_time(base::Time::Now()); | 221 updated_request.set_last_attempt_time(base::Time::Now()); |
| 222 RequestQueue::UpdateRequestCallback update_callback = | 222 RequestQueue::UpdateRequestCallback update_callback = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 240 return trigger_conditions; | 240 return trigger_conditions; |
| 241 } | 241 } |
| 242 | 242 |
| 243 void RequestCoordinator::GetOffliner() { | 243 void RequestCoordinator::GetOffliner() { |
| 244 if (!offliner_) { | 244 if (!offliner_) { |
| 245 offliner_ = factory_->GetOffliner(policy_.get()); | 245 offliner_ = factory_->GetOffliner(policy_.get()); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace offline_pages | 249 } // namespace offline_pages |
| OLD | NEW |