Skip to content

Commit

Permalink
Review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cypt4 committed Aug 15, 2022
1 parent ef4ecfc commit 2a84b32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions browser/ipfs/ipfs_dns_resolver_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

#include "brave/browser/ipfs/ipfs_dns_resolver_impl.h"

#include "base/time/time.h"
#include "chrome/browser/net/secure_dns_config.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "services/network/public/mojom/network_service.mojom.h"

namespace ipfs {

const int kThrottleDeltaMs = 1000;
constexpr base::TimeDelta kRetryDelay = base::Seconds(1);

mojo::Remote<network::mojom::DnsConfigChangeManager>
GetDnsConfigChangeManager() {
Expand Down Expand Up @@ -43,11 +44,12 @@ IpfsDnsResolverImpl::~IpfsDnsResolverImpl() {}
void IpfsDnsResolverImpl::OnDnsConfigChangeManagerConnectionError() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
receiver_.reset();
// Throttle network service reconnect to prevent possible battery drain.
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&IpfsDnsResolverImpl::SetupDnsConfigChangeNotifications,
weak_ptr_factory_.GetWeakPtr()),
base::Milliseconds(kThrottleDeltaMs));
kRetryDelay);
}

void IpfsDnsResolverImpl::OnDnsConfigChanged() {
Expand Down

0 comments on commit 2a84b32

Please sign in to comment.