| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This implementation of NetworkChangeNotifier's offline state detection | 5 // This implementation of NetworkChangeNotifier's offline state detection |
| 6 // depends on D-Bus and NetworkManager, and is known to work on at least | 6 // depends on D-Bus and NetworkManager, and is known to work on at least |
| 7 // GNOME version 2.30. If D-Bus or NetworkManager are unavailable, this | 7 // GNOME version 2.30. If D-Bus or NetworkManager are unavailable, this |
| 8 // implementation will always behave as if it is online. | 8 // implementation will always behave as if it is online. |
| 9 | 9 |
| 10 #include "net/base/network_change_notifier_linux.h" | 10 #include "net/base/network_change_notifier_linux.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 if (!system_bus_) { | 131 if (!system_bus_) { |
| 132 dbus::Bus::Options options; | 132 dbus::Bus::Options options; |
| 133 options.bus_type = dbus::Bus::SYSTEM; | 133 options.bus_type = dbus::Bus::SYSTEM; |
| 134 options.connection_type = dbus::Bus::PRIVATE; | 134 options.connection_type = dbus::Bus::PRIVATE; |
| 135 system_bus_ = new dbus::Bus(options); | 135 system_bus_ = new dbus::Bus(options); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Ignore ServiceUnknown errors to avoid log spam: http://crbug.com/109696. | 138 // Ignore ServiceUnknown errors to avoid log spam: http://crbug.com/109696. |
| 139 dbus::ObjectProxy* proxy = system_bus_->GetObjectProxyWithOptions( | 139 dbus::ObjectProxy* proxy = system_bus_->GetObjectProxyWithOptions( |
| 140 kNetworkManagerServiceName, kNetworkManagerPath, | 140 kNetworkManagerServiceName, dbus::ObjectPath(kNetworkManagerPath), |
| 141 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); | 141 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); |
| 142 | 142 |
| 143 // Get the initial state asynchronously. | 143 // Get the initial state asynchronously. |
| 144 dbus::MethodCall method_call(DBUS_INTERFACE_PROPERTIES, "Get"); | 144 dbus::MethodCall method_call(DBUS_INTERFACE_PROPERTIES, "Get"); |
| 145 dbus::MessageWriter builder(&method_call); | 145 dbus::MessageWriter builder(&method_call); |
| 146 builder.AppendString(kNetworkManagerInterface); | 146 builder.AppendString(kNetworkManagerInterface); |
| 147 builder.AppendString("State"); | 147 builder.AppendString("State"); |
| 148 proxy->CallMethod( | 148 proxy->CallMethod( |
| 149 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 149 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 150 base::Bind(&NetworkManagerApi::OnInitialResponse, | 150 base::Bind(&NetworkManagerApi::OnInitialResponse, |
| 151 ptr_factory_.GetWeakPtr())); | 151 ptr_factory_.GetWeakPtr())); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // Stopping from here allows us to sanity- check that the notifier | 458 // Stopping from here allows us to sanity- check that the notifier |
| 459 // thread shut down properly. | 459 // thread shut down properly. |
| 460 notifier_thread_->Stop(); | 460 notifier_thread_->Stop(); |
| 461 } | 461 } |
| 462 | 462 |
| 463 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { | 463 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { |
| 464 return notifier_thread_->IsCurrentlyOffline(); | 464 return notifier_thread_->IsCurrentlyOffline(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 } // namespace net | 467 } // namespace net |
| OLD | NEW |