Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: net/base/network_change_notifier_linux.cc

Issue 8591021: Fix initial offline state response handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/network_change_notifier_linux_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_change_notifier_linux.cc
diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc
index 95f54e24e5070e32ec0e06ef24fc2292c18e1c32..fbefffb70558ce6aa9e62bd32dc151aa5f01bff3 100644
--- a/net/base/network_change_notifier_linux.cc
+++ b/net/base/network_change_notifier_linux.cc
@@ -88,16 +88,8 @@ class NetworkManagerApi {
private:
// Callbacks for D-Bus API.
- void OnStateChanged(dbus::Message* message);
-
- void OnResponse(dbus::Response* response) {
- OnStateChanged(response);
- offline_state_initialized_.Signal();
- }
-
- void OnSignaled(dbus::Signal* signal) {
- OnStateChanged(signal);
- }
+ void OnResponse(dbus::Response* response);
+ void OnSignaled(dbus::Signal* signal);
void OnConnected(const std::string&, const std::string&, bool success) {
if (!success) {
@@ -162,17 +154,35 @@ void NetworkManagerApi::CleanUp() {
ptr_factory_.InvalidateWeakPtrs();
}
-void NetworkManagerApi::OnStateChanged(dbus::Message* message) {
+void NetworkManagerApi::OnResponse(dbus::Response* response) {
DCHECK_EQ(helper_thread_id_, base::PlatformThread::CurrentId());
- if (!message) {
+ if (!response) {
DLOG(WARNING) << "No response received for initial state request";
+ offline_state_initialized_.Signal();
return;
}
- dbus::MessageReader reader(message);
+ dbus::MessageReader reader(response);
uint32 state = 0;
- if (!reader.HasMoreData() || !reader.PopUint32(&state)) {
+ if (!reader.HasMoreData() || !reader.PopVariantOfUint32(&state)) {
satorux1 2011/11/17 17:40:15 You don't need !reader.HasMoreData(). PopVariantOf
adamk 2011/11/17 18:58:24 Good to know, done.
DLOG(WARNING) << "Unexpected response for NetworkManager State request: "
- << message->ToString();
+ << response->ToString();
+ offline_state_initialized_.Signal();
+ return;
+ }
+ {
+ base::AutoLock lock(is_offline_lock_);
+ is_offline_ = StateIsOffline(state);
+ }
+ offline_state_initialized_.Signal();
satorux1 2011/11/17 17:40:15 Calling offline_state_initialized_.Signal() from t
adamk 2011/11/17 18:58:24 Yeah, I agree; this is covered by the unittests, b
+}
+
+void NetworkManagerApi::OnSignaled(dbus::Signal* signal) {
+ DCHECK_EQ(helper_thread_id_, base::PlatformThread::CurrentId());
+ dbus::MessageReader reader(signal);
+ uint32 state = 0;
+ if (!reader.HasMoreData() || !reader.PopUint32(&state)) {
satorux1 2011/11/17 17:40:15 You can remove !reader.HasMoreData() from here too
adamk 2011/11/17 18:58:24 Done.
+ DLOG(WARNING) << "Unexpected signal for NetworkManager StateChanged: "
+ << signal->ToString();
return;
}
bool new_is_offline = StateIsOffline(state);
@@ -183,8 +193,7 @@ void NetworkManagerApi::OnStateChanged(dbus::Message* message) {
else
return;
}
- if (offline_state_initialized_.IsSignaled())
- notification_callback_.Run();
+ notification_callback_.Run();
}
bool NetworkManagerApi::StateIsOffline(uint32 state) {
« no previous file with comments | « no previous file | net/base/network_change_notifier_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698