buffet: XmppChannel listens for connectivity changes
ShillClent provides notifications for network changes.
XmppChannel issue XMPP ping on every network change and restart if
failed. Only exception is soon scheduled upcoming reconnect.
BUG=brillo:1139
TEST=register device, disconnect network, wait device is offline in
GCD dashboard, connect network.
Dashboard should show device as online in less then 60 seconds.
Change-Id: I73dffc54400777b2325c26fb8aaf259b515174ce
Reviewed-on: https://chromium-review.googlesource.com/281413
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/privet/shill_client.cc b/buffet/privet/shill_client.cc
index 0a1b2e2..48d0cef 100644
--- a/buffet/privet/shill_client.cc
+++ b/buffet/privet/shill_client.cc
@@ -464,19 +464,20 @@
new_connectivity_state = kv.second.service_state;
}
}
- VLOG(3) << "New connectivity state is "
+ VLOG(1) << "Connectivity changed: "
+ << ServiceStateToString(connectivity_state_) << " -> "
<< ServiceStateToString(new_connectivity_state);
- if (new_connectivity_state != connectivity_state_) {
- connectivity_state_ = new_connectivity_state;
- // We may call UpdateConnectivityState whenever we mutate a data structure
- // such that our connectivity status could change. However, we don't want
- // to allow people to call into ShillClient while some other operation is
- // underway. Therefore, call our callbacks later, when we're in a good
- // state.
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ShillClient::NotifyConnectivityListeners,
- weak_factory_.GetWeakPtr(), AmOnline()));
- }
+ // Notify listeners even if state changed to the same value. Listeners may
+ // want to handle this event.
+ connectivity_state_ = new_connectivity_state;
+ // We may call UpdateConnectivityState whenever we mutate a data structure
+ // such that our connectivity status could change. However, we don't want
+ // to allow people to call into ShillClient while some other operation is
+ // underway. Therefore, call our callbacks later, when we're in a good
+ // state.
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&ShillClient::NotifyConnectivityListeners,
+ weak_factory_.GetWeakPtr(), AmOnline()));
}
void ShillClient::NotifyConnectivityListeners(bool am_online) {