Remove bool argument from OnConnectionChangedCallback We don't want to assert that implementation will have correct implementation. BUG: 24267885 Change-Id: I50b57de19253b32f1282820c2320ad366d0b5ffd Reviewed-on: https://weave-review.googlesource.com/1099 Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/libweave/examples/ubuntu/network_manager.cc b/libweave/examples/ubuntu/network_manager.cc index 2d77309..a054d24 100644 --- a/libweave/examples/ubuntu/network_manager.cc +++ b/libweave/examples/ubuntu/network_manager.cc
@@ -338,9 +338,8 @@ } void NetworkImpl::NotifyNetworkChanged() { - bool online = GetConnectionState() == NetworkState::kConnected; for (const auto& i : callbacks_) - i.Run(online); + i.Run(); } void NetworkImpl::OpenSslSocket(
diff --git a/libweave/include/weave/network.h b/libweave/include/weave/network.h index 0f0b12b..3ae70c0 100644 --- a/libweave/include/weave/network.h +++ b/libweave/include/weave/network.h
@@ -24,9 +24,9 @@ class Network { public: // A callback that interested parties can register to be notified of - // transitions from online to offline and vice versa. The boolean - // parameter will be true if we're online, and false if we're offline. - using OnConnectionChangedCallback = base::Callback<void(bool)>; + // connectivity changes. Changes may include but not limited: interface + // up or down, new IP is assigned, cable is disconnected. + using OnConnectionChangedCallback = base::Callback<void()>; virtual void AddOnConnectionChangedCallback( const OnConnectionChangedCallback& listener) = 0;
diff --git a/libweave/src/notification/xmpp_channel.cc b/libweave/src/notification/xmpp_channel.cc index ce0c001..1acb679 100644 --- a/libweave/src/notification/xmpp_channel.cc +++ b/libweave/src/notification/xmpp_channel.cc
@@ -457,7 +457,7 @@ Restart(); } -void XmppChannel::OnConnectivityChanged(bool online) { +void XmppChannel::OnConnectivityChanged() { if (state_ == XmppState::kNotStarted) return;
diff --git a/libweave/src/notification/xmpp_channel.h b/libweave/src/notification/xmpp_channel.h index ddbdee1..d1664f6 100644 --- a/libweave/src/notification/xmpp_channel.h +++ b/libweave/src/notification/xmpp_channel.h
@@ -118,7 +118,7 @@ void OnPingResponse(base::Time sent_time, std::unique_ptr<XmlNode> reply); void OnPingTimeout(base::Time sent_time); - void OnConnectivityChanged(bool online); + void OnConnectivityChanged(); XmppState state_{XmppState::kNotStarted};
diff --git a/libweave/src/privet/privet_manager.cc b/libweave/src/privet/privet_manager.cc index 2541908..2c581f7 100644 --- a/libweave/src/privet/privet_manager.cc +++ b/libweave/src/privet/privet_manager.cc
@@ -154,7 +154,7 @@ publisher_->Update(); } -void Manager::OnConnectivityChanged(bool online) { +void Manager::OnConnectivityChanged() { OnChanged(); }
diff --git a/libweave/src/privet/privet_manager.h b/libweave/src/privet/privet_manager.h index f9ccd15..cc9ccc5 100644 --- a/libweave/src/privet/privet_manager.h +++ b/libweave/src/privet/privet_manager.h
@@ -80,7 +80,7 @@ const HttpServer::OnReplyCallback& callback); void OnChanged(); - void OnConnectivityChanged(bool online); + void OnConnectivityChanged(); void OnHttpServerStatusChanged(const HttpServer& server);
diff --git a/libweave/src/privet/wifi_bootstrap_manager.cc b/libweave/src/privet/wifi_bootstrap_manager.cc index 1f79606..0dede94 100644 --- a/libweave/src/privet/wifi_bootstrap_manager.cc +++ b/libweave/src/privet/wifi_bootstrap_manager.cc
@@ -227,12 +227,14 @@ StartBootstrapping(); } -void WifiBootstrapManager::OnConnectivityChange(bool is_connected) { - VLOG(3) << "ConnectivityChanged: " << is_connected; +void WifiBootstrapManager::OnConnectivityChange() { + VLOG(3) << "ConnectivityChanged: " + << EnumToString(network_->GetConnectionState()); UpdateConnectionState(); if (state_ == State::kMonitoring || // Reset monitoring timeout. - (state_ == State::kDisabled && is_connected)) { + (state_ == State::kDisabled && + network_->GetConnectionState() == NetworkState::kConnected)) { StartMonitoring(); } }
diff --git a/libweave/src/privet/wifi_bootstrap_manager.h b/libweave/src/privet/wifi_bootstrap_manager.h index f32340d..65436c2 100644 --- a/libweave/src/privet/wifi_bootstrap_manager.h +++ b/libweave/src/privet/wifi_bootstrap_manager.h
@@ -85,7 +85,7 @@ void OnBootstrapTimeout(); void OnConnectTimeout(); void OnConnectSuccess(const std::string& ssid); - void OnConnectivityChange(bool is_connected); + void OnConnectivityChange(); void OnMonitorTimeout(); void UpdateConnectionState();
diff --git a/libweave/src/weave_unittest.cc b/libweave/src/weave_unittest.cc index a957f1c..cc3ace3 100644 --- a/libweave/src/weave_unittest.cc +++ b/libweave/src/weave_unittest.cc
@@ -408,12 +408,12 @@ EXPECT_CALL(network_, GetConnectionState()) .WillRepeatedly(Return(NetworkState::kOffline)); for (const auto& cb : network_callbacks_) { - task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb, false), {}); + task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb), {}); } EXPECT_CALL(network_, GetConnectionState()) .WillRepeatedly(Return(NetworkState::kConnected)); for (const auto& cb : network_callbacks_) { - task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb, true), + task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb), base::TimeDelta::FromSeconds(10)); } task_runner_.Run(); @@ -422,7 +422,7 @@ EXPECT_CALL(network_, GetConnectionState()) .WillRepeatedly(Return(NetworkState::kOffline)); for (const auto& cb : network_callbacks_) { - task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb, false), {}); + task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb), {}); } auto offline_from = task_runner_.GetClock()->Now(); EXPECT_CALL(network_, EnableAccessPoint(MatchesRegex("DEVICE_NAME.*prv"))) @@ -445,7 +445,7 @@ EXPECT_CALL(network_, GetConnectionState()) .WillRepeatedly(Return(NetworkState::kOffline)); for (const auto& cb : network_callbacks_) { - task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb, false), {}); + task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb), {}); } for (int i = 0; i < 5; ++i) { @@ -473,7 +473,7 @@ EXPECT_CALL(network_, GetConnectionState()) .WillRepeatedly(Return(NetworkState::kConnected)); for (const auto& cb : network_callbacks_) - task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb, true), {}); + task_runner_.PostDelayedTask(FROM_HERE, base::Bind(cb), {}); task_runner_.Run(); }