Commit c7577d5d authored by Lily Houghton's avatar Lily Houghton Committed by Commit Bot

Change AffiliationFetchThrottler to use NetworkChangeObserver

ConnectionTypeObserver is deprecated.  This CL modifies AffiliationFetchThrottler
to use NetworkChangeObserver instead.

For more details, see the linked design doc in the bug below.

Bug: 754695
Change-Id: I38b53ce245a74c19be41aab2558a9c3e7fc7b1d1
Reviewed-on: https://chromium-review.googlesource.com/1134019Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Lily Houghton <lilyhoughton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576188}
parent e44ec9d0
...@@ -64,12 +64,12 @@ AffiliationFetchThrottler::AffiliationFetchThrottler( ...@@ -64,12 +64,12 @@ AffiliationFetchThrottler::AffiliationFetchThrottler(
DCHECK(delegate); DCHECK(delegate);
// Start observing before querying the current connectivity state, so that if // Start observing before querying the current connectivity state, so that if
// the state changes concurrently in-between, it will not go unnoticed. // the state changes concurrently in-between, it will not go unnoticed.
net::NetworkChangeNotifier::AddConnectionTypeObserver(this); net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
has_network_connectivity_ = !net::NetworkChangeNotifier::IsOffline(); has_network_connectivity_ = !net::NetworkChangeNotifier::IsOffline();
} }
AffiliationFetchThrottler::~AffiliationFetchThrottler() { AffiliationFetchThrottler::~AffiliationFetchThrottler() {
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
} }
void AffiliationFetchThrottler::SignalNetworkRequestNeeded() { void AffiliationFetchThrottler::SignalNetworkRequestNeeded() {
...@@ -108,7 +108,7 @@ void AffiliationFetchThrottler::OnBackoffDelayExpiredCallback() { ...@@ -108,7 +108,7 @@ void AffiliationFetchThrottler::OnBackoffDelayExpiredCallback() {
is_fetch_scheduled_ = false; is_fetch_scheduled_ = false;
// Do nothing if network connectivity was lost while this callback was in the // Do nothing if network connectivity was lost while this callback was in the
// task queue. The callback will be posted in the OnConnectionTypeChanged // task queue. The callback will be posted in the OnNetworkChanged
// handler once again. // handler once again.
if (!has_network_connectivity_) if (!has_network_connectivity_)
return; return;
...@@ -121,7 +121,7 @@ void AffiliationFetchThrottler::OnBackoffDelayExpiredCallback() { ...@@ -121,7 +121,7 @@ void AffiliationFetchThrottler::OnBackoffDelayExpiredCallback() {
state_ = delegate_->OnCanSendNetworkRequest() ? FETCH_IN_FLIGHT : IDLE; state_ = delegate_->OnCanSendNetworkRequest() ? FETCH_IN_FLIGHT : IDLE;
} }
void AffiliationFetchThrottler::OnConnectionTypeChanged( void AffiliationFetchThrottler::OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) { net::NetworkChangeNotifier::ConnectionType type) {
bool old_has_network_connectivity = has_network_connectivity_; bool old_has_network_connectivity = has_network_connectivity_;
has_network_connectivity_ = has_network_connectivity_ =
......
...@@ -50,7 +50,7 @@ class AffiliationFetchThrottlerDelegate; ...@@ -50,7 +50,7 @@ class AffiliationFetchThrottlerDelegate;
// periods, so that requests will not be held back for too long after // periods, so that requests will not be held back for too long after
// connectivity is restored. // connectivity is restored.
class AffiliationFetchThrottler class AffiliationFetchThrottler
: public net::NetworkChangeNotifier::ConnectionTypeObserver { : public net::NetworkChangeNotifier::NetworkChangeObserver {
public: public:
// Creates an instance that will use |tick_clock| as its tick source, and will // Creates an instance that will use |tick_clock| as its tick source, and will
// post to |task_runner| to call the |delegate|'s OnSendNetworkRequest(). The // post to |task_runner| to call the |delegate|'s OnSendNetworkRequest(). The
...@@ -114,8 +114,8 @@ class AffiliationFetchThrottler ...@@ -114,8 +114,8 @@ class AffiliationFetchThrottler
// Called back when the |exponential_backoff_| delay expires. // Called back when the |exponential_backoff_| delay expires.
void OnBackoffDelayExpiredCallback(); void OnBackoffDelayExpiredCallback();
// net::NetworkChangeNotifier::ConnectionTypeObserver: // net::NetworkChangeNotifier::NetworkChangeObserver:
void OnConnectionTypeChanged( void OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) override; net::NetworkChangeNotifier::ConnectionType type) override;
scoped_refptr<base::SequencedTaskRunner> task_runner_; scoped_refptr<base::SequencedTaskRunner> task_runner_;
......
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