Skip to content

Commit

Permalink
Fixed failed payment balances do not retry unless browser is restarte…
Browse files Browse the repository at this point in the history
…d or ad grant is claimed

Fixes brave/brave-browser#5175
  • Loading branch information
tmancey authored Jul 23, 2019
1 parent e104809 commit fd55545
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void AdsRewards::Update(
return;
}

CancelRetry();

BLOG(INFO) << "Fetch ads rewards";
GetPaymentBalance();
}
Expand Down Expand Up @@ -100,7 +102,7 @@ bool AdsRewards::OnTimer(const uint32_t timer_id) {
<< " retry_timer_id_: " << std::to_string(retry_timer_id_) << std::endl;

if (timer_id == retry_timer_id_) {
Retry();
GetPaymentBalance();

return true;
}
Expand Down Expand Up @@ -238,14 +240,13 @@ void AdsRewards::OnAdsRewards(const Result result) {

BLOG(INFO) << "Successfully retrieved ads rewards";

retry_timer_id_ = 0;
next_retry_start_timer_in_ = 0;

Update();
}

void AdsRewards::Retry() {
CancelRetry();

if (next_retry_start_timer_in_ == 0) {
next_retry_start_timer_in_ = 2 * base::Time::kSecondsPerMinute;
} else {
Expand Down Expand Up @@ -273,6 +274,8 @@ void AdsRewards::CancelRetry() {

confirmations_client_->KillTimer(retry_timer_id_);
retry_timer_id_ = 0;

next_retry_backoff_count_ = 0;
}

bool AdsRewards::IsRetrying() const {
Expand Down

0 comments on commit fd55545

Please sign in to comment.