OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ | 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ |
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ | 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "net/base/network_change_notifier.h" | 12 #include "net/base/network_change_notifier.h" |
13 | 13 |
14 namespace dbus { | |
15 class Bus; | |
16 } | |
17 | |
18 namespace net { | 14 namespace net { |
19 | 15 |
20 class NetworkChangeNotifierLinux : public NetworkChangeNotifier { | 16 class NetworkChangeNotifierLinux : public NetworkChangeNotifier { |
21 public: | 17 public: |
22 static NetworkChangeNotifierLinux* Create(); | 18 NetworkChangeNotifierLinux(); |
23 | |
24 // Unittests inject a mock bus. | |
25 static NetworkChangeNotifierLinux* CreateForTest(dbus::Bus* bus); | |
26 | 19 |
27 private: | 20 private: |
28 class Thread; | 21 class Thread; |
29 | 22 |
30 explicit NetworkChangeNotifierLinux(dbus::Bus* bus); | |
31 virtual ~NetworkChangeNotifierLinux(); | 23 virtual ~NetworkChangeNotifierLinux(); |
32 | 24 |
33 // NetworkChangeNotifier: | 25 // NetworkChangeNotifier: |
34 virtual bool IsCurrentlyOffline() const OVERRIDE; | 26 virtual bool IsCurrentlyOffline() const OVERRIDE; |
35 | 27 |
36 // The thread used to listen for notifications. This relays the notification | 28 // The thread used to listen for notifications. This relays the notification |
37 // to the registered observers without posting back to the thread the object | 29 // to the registered observers without posting back to the thread the object |
38 // was created on. | 30 // was created on. |
39 scoped_ptr<Thread> notifier_thread_; | 31 scoped_ptr<Thread> notifier_thread_; |
40 | 32 |
41 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux); | 33 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux); |
42 }; | 34 }; |
43 | 35 |
44 } // namespace net | 36 } // namespace net |
45 | 37 |
46 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ | 38 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ |
OLD | NEW |