diff options
author | Vitaly Buka <vitalybuka@google.com> | 2016-02-26 17:30:59 -0800 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2016-02-26 20:13:29 -0800 |
commit | 026dce2bce26ca52933ce10e200a196a6b59a63c (patch) | |
tree | 39f5a9a7622e4ab2dad18fb23935156b230b5cbd | |
parent | 98b3323fbf2357e69dc8b3585fcf1e5e496cd82c (diff) | |
download | weaved-026dce2bce26ca52933ce10e200a196a6b59a63c.tar.gz |
Remove connectivity_state_ member
This value can be easily calculate from devices_.
Change-Id: I1da30d04991dd08f0b89600632ed9e818d9f6b2a
-rw-r--r-- | buffet/shill_client.cc | 23 | ||||
-rw-r--r-- | buffet/shill_client.h | 1 |
2 files changed, 7 insertions, 17 deletions
diff --git a/buffet/shill_client.cc b/buffet/shill_client.cc index 88fbc84..dea039d 100644 --- a/buffet/shill_client.cc +++ b/buffet/shill_client.cc @@ -123,7 +123,6 @@ void ShillClient::Init() { VLOG(2) << "ShillClient::Init();"; CleanupConnectingService(); devices_.clear(); - connectivity_state_ = Network::State::kOffline; VariantDictionary properties; if (!manager_proxy_.GetProperties(&properties, nullptr)) { LOG(ERROR) << "Unable to get properties from Manager, waiting for " @@ -198,7 +197,12 @@ void ShillClient::ConnectToServiceError( } Network::State ShillClient::GetConnectionState() const { - return connectivity_state_; + Network::State new_connectivity_state{Network::State::kOffline}; + for (const auto& kv : devices_) { + new_connectivity_state = + std::max(new_connectivity_state, kv.second.service_state); + } + return new_connectivity_state; } void ShillClient::StartAccessPoint(const std::string& ssid) { @@ -239,7 +243,6 @@ void ShillClient::OnShillServiceOwnerChange(const string& /*old_owner*/, if (new_owner.empty()) { CleanupConnectingService(); devices_.clear(); - connectivity_state_ = Network::State::kOffline; } else { Init(); // New service owner means shill reset! } @@ -553,19 +556,7 @@ void ShillClient::OnStateChangeForSelectedService( } void ShillClient::UpdateConnectivityState() { - // Update the connectivity state of the device by picking the - // state of the currently most connected selected service. - Network::State new_connectivity_state{Network::State::kOffline}; - for (const auto& kv : devices_) { - if (kv.second.service_state > new_connectivity_state) { - new_connectivity_state = kv.second.service_state; - } - } - VLOG(1) << "Connectivity changed: " << EnumToString(connectivity_state_) - << " -> " << EnumToString(new_connectivity_state); - // Notify listeners even if state changed to the same value. Listeners may - // want to handle this event. - connectivity_state_ = new_connectivity_state; + VLOG(1) << "Connectivity state: " << EnumToString(GetConnectionState()); // 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 diff --git a/buffet/shill_client.h b/buffet/shill_client.h index 12fd619..6407a33 100644 --- a/buffet/shill_client.h +++ b/buffet/shill_client.h @@ -130,7 +130,6 @@ class ShillClient final : public weave::provider::Network, // State for tracking our online connectivity. std::map<dbus::ObjectPath, DeviceState> devices_; - State connectivity_state_{State::kOffline}; std::unique_ptr<ApManagerClient> ap_manager_client_; |