| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 is_busy_ = false; | 440 is_busy_ = false; |
| 441 active_request_.reset(nullptr); | 441 active_request_.reset(nullptr); |
| 442 | 442 |
| 443 if (status == Offliner::RequestStatus::FOREGROUND_CANCELED || | 443 if (status == Offliner::RequestStatus::FOREGROUND_CANCELED || |
| 444 status == Offliner::RequestStatus::PRERENDERING_CANCELED) { | 444 status == Offliner::RequestStatus::PRERENDERING_CANCELED) { |
| 445 // Update the request for the canceled attempt. | 445 // Update the request for the canceled attempt. |
| 446 // TODO(dougarnett): See if we can conclusively identify other attempt | 446 // TODO(dougarnett): See if we can conclusively identify other attempt |
| 447 // aborted cases to treat this way (eg, for Render Process Killed). | 447 // aborted cases to treat this way (eg, for Render Process Killed). |
| 448 SavePageRequest updated_request(request); | 448 SavePageRequest updated_request(request); |
| 449 AbortRequestAttempt(&updated_request); | 449 AbortRequestAttempt(&updated_request); |
| 450 SavePageStatus notify_status = | 450 NotifyChanged(updated_request); |
| 451 (status == Offliner::RequestStatus::FOREGROUND_CANCELED) | |
| 452 ? SavePageStatus::FOREGROUND_CANCELED | |
| 453 : SavePageStatus::PRERENDER_CANCELED; | |
| 454 NotifyCompleted(updated_request, notify_status); | |
| 455 } else if (status == Offliner::RequestStatus::SAVED) { | 451 } else if (status == Offliner::RequestStatus::SAVED) { |
| 456 // Remove the request from the queue if it succeeded. | 452 // Remove the request from the queue if it succeeded. |
| 457 RemoveAttemptedRequest(request, SavePageStatus::SUCCESS); | 453 RemoveAttemptedRequest(request, SavePageStatus::SUCCESS); |
| 458 } else if (request.completed_attempt_count() + 1 >= | 454 } else if (request.completed_attempt_count() + 1 >= |
| 459 policy_->GetMaxCompletedTries()) { | 455 policy_->GetMaxCompletedTries()) { |
| 460 // Remove from the request queue if we exceeded max retries. The +1 | 456 // Remove from the request queue if we exceeded max retries. The +1 |
| 461 // represents the request that just completed. Since we call | 457 // represents the request that just completed. Since we call |
| 462 // MarkAttemptCompleted within the if branches, the completed_attempt_count | 458 // MarkAttemptCompleted within the if branches, the completed_attempt_count |
| 463 // has not yet been updated when we are checking the if condition. | 459 // has not yet been updated when we are checking the if condition. |
| 464 RemoveAttemptedRequest(request, SavePageStatus::RETRY_COUNT_EXCEEDED); | 460 RemoveAttemptedRequest(request, SavePageStatus::RETRY_COUNT_EXCEEDED); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); | 525 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); |
| 530 } | 526 } |
| 531 | 527 |
| 532 void RequestCoordinator::GetOffliner() { | 528 void RequestCoordinator::GetOffliner() { |
| 533 if (!offliner_) { | 529 if (!offliner_) { |
| 534 offliner_ = factory_->GetOffliner(policy_.get()); | 530 offliner_ = factory_->GetOffliner(policy_.get()); |
| 535 } | 531 } |
| 536 } | 532 } |
| 537 | 533 |
| 538 } // namespace offline_pages | 534 } // namespace offline_pages |
| OLD | NEW |