Commit c367e9d9 authored by Candice Sy's avatar Candice Sy Committed by Commit Bot

Decrease the started_attempt_count_ for paused offlining requests.

This is a fix for the bug where 5 user pauses of an offlining request
fails the request because there is a max of 5 tries per request.
Decreasing the started_attempt_count_ when pausing an offlining request
undos the incrementation of the counter when the request began
offlining.

Bug: 701037
Change-Id: I721b41bd9e9a1c366c9fe7f5896f5627e8d8fb1a
Reviewed-on: https://chromium-review.googlesource.com/957423
Commit-Queue: Candice Sy <cmsy@google.com>
Reviewed-by: default avatarYafei Duan <romax@chromium.org>
Reviewed-by: default avatarPeter Williamson <petewil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543879}
parent c972bfd1
......@@ -44,6 +44,12 @@ void ChangeRequestsStateTask::UpdateRequests(
// of the missing items will be added at the end.
std::vector<SavePageRequest> items_to_update;
for (auto request : read_result->updated_items) {
// Decrease the started_attempt_count_ for offlining requests paused by the
// user (https://crbug.com/701037).
if (request.request_state() == SavePageRequest::RequestState::OFFLINING &&
new_state_ == SavePageRequest::RequestState::PAUSED) {
request.set_started_attempt_count(request.started_attempt_count() - 1);
}
request.set_request_state(new_state_);
items_to_update.push_back(request);
}
......
......@@ -59,12 +59,13 @@ void SavePageRequest::MarkAttemptCompleted() {
}
void SavePageRequest::MarkAttemptAborted() {
DCHECK_GT(started_attempt_count_, 0);
// We intentinally do not increment the completed_attempt_count_, since this
// was killed before it completed, so we could use the phone or browser for
// other things.
if (state_ == RequestState::OFFLINING)
if (state_ == RequestState::OFFLINING) {
DCHECK_GT(started_attempt_count_, 0);
state_ = RequestState::AVAILABLE;
}
}
void SavePageRequest::MarkAttemptPaused() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment