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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 scoped_refptr<dbus::Bus> system_bus_; | 117 scoped_refptr<dbus::Bus> system_bus_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(NetworkManagerApi); | 119 DISALLOW_COPY_AND_ASSIGN(NetworkManagerApi); |
120 }; | 120 }; |
121 | 121 |
122 void NetworkManagerApi::Init() { | 122 void NetworkManagerApi::Init() { |
123 // D-Bus requires an IO MessageLoop. | 123 // D-Bus requires an IO MessageLoop. |
124 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_IO); | 124 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_IO); |
125 helper_thread_id_ = base::PlatformThread::CurrentId(); | 125 helper_thread_id_ = base::PlatformThread::CurrentId(); |
126 | 126 |
127 if (!system_bus_) { | 127 if (!system_bus_.get()) { |
128 dbus::Bus::Options options; | 128 dbus::Bus::Options options; |
129 options.bus_type = dbus::Bus::SYSTEM; | 129 options.bus_type = dbus::Bus::SYSTEM; |
130 options.connection_type = dbus::Bus::PRIVATE; | 130 options.connection_type = dbus::Bus::PRIVATE; |
131 system_bus_ = new dbus::Bus(options); | 131 system_bus_ = new dbus::Bus(options); |
132 } | 132 } |
133 | 133 |
134 // Ignore ServiceUnknown errors to avoid log spam: http://crbug.com/109696. | 134 // Ignore ServiceUnknown errors to avoid log spam: http://crbug.com/109696. |
135 dbus::ObjectProxy* proxy = system_bus_->GetObjectProxyWithOptions( | 135 dbus::ObjectProxy* proxy = system_bus_->GetObjectProxyWithOptions( |
136 kNetworkManagerServiceName, dbus::ObjectPath(kNetworkManagerPath), | 136 kNetworkManagerServiceName, dbus::ObjectPath(kNetworkManagerPath), |
137 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); | 137 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 NetworkChangeNotifierLinux::GetCurrentConnectionType() const { | 324 NetworkChangeNotifierLinux::GetCurrentConnectionType() const { |
325 return notifier_thread_->GetCurrentConnectionType(); | 325 return notifier_thread_->GetCurrentConnectionType(); |
326 } | 326 } |
327 | 327 |
328 const internal::AddressTrackerLinux* | 328 const internal::AddressTrackerLinux* |
329 NetworkChangeNotifierLinux::GetAddressTrackerInternal() const { | 329 NetworkChangeNotifierLinux::GetAddressTrackerInternal() const { |
330 return notifier_thread_->address_tracker(); | 330 return notifier_thread_->address_tracker(); |
331 } | 331 } |
332 | 332 |
333 } // namespace net | 333 } // namespace net |
OLD | NEW |