OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROMEOS_NETWORK_CONNECTION_CHANGE_NOTIFIER_H_ | |
6 #define CHROMEOS_NETWORK_CONNECTION_CHANGE_NOTIFIER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "chromeos/network/network_state_handler_observer.h" | |
13 #include "net/base/net_export.h" | |
14 #include "net/base/network_change_notifier.h" | |
15 #include "net/dns/dns_config_service_posix.h" | |
16 | |
17 namespace net { | |
18 | |
19 class NET_EXPORT_PRIVATE NetworkChangeNotifierChromeos | |
20 : public NetworkChangeNotifier, | |
21 public chromeos::NetworkStateHandlerObserver { | |
22 public: | |
23 NetworkChangeNotifierChromeos(); | |
24 virtual ~NetworkChangeNotifierChromeos(); | |
25 | |
26 // Initialize the connection change notifier. Start observing | |
27 // changes from the network state handler. | |
stevenjb
2012/12/13 19:28:22
Simplify to: Starts observing changes from the net
gauravsh
2012/12/15 00:42:45
Done.
| |
28 void Initialize(); | |
29 | |
30 // Shutdown the connection change notifier. Stop observing | |
31 // changes from the network state handler. | |
stevenjb
2012/12/13 19:28:22
dito. s/Stop/Stops
gauravsh
2012/12/15 00:42:45
Done.
| |
32 void Shutdown(); | |
33 | |
34 // NetworkChangeNotifier overrides. | |
35 NetworkChangeNotifier::ConnectionType | |
36 GetCurrentConnectionType() const OVERRIDE; | |
37 | |
38 // NetworkStateHandlerObserver overrides. | |
39 void ActiveNetworkChanged( | |
40 const chromeos::NetworkState* active_network) OVERRIDE; | |
41 void ActiveNetworkStateChanged( | |
42 const chromeos::NetworkState* active_network) OVERRIDE; | |
43 | |
44 private: | |
45 friend class NetworkChangeNotifierChromeosUpdateTest; | |
46 | |
47 class DnsConfigService : public net::internal::DnsConfigServicePosix { | |
stevenjb
2012/12/13 19:28:22
We can define this only in the .cc file and forwar
gauravsh
2012/12/15 00:42:45
Done.
| |
48 public: | |
49 DnsConfigService(); | |
50 virtual ~DnsConfigService(); | |
51 | |
52 // net::internal::DnsConfigService() overrides. | |
53 virtual bool StartWatching() OVERRIDE; | |
54 | |
55 virtual void OnNetworkChange(); | |
56 }; | |
57 | |
58 // Updates the state based on an active network update. | |
59 // |connection_type_changed| is set to true if we must report a connection | |
60 // type change. | |
61 // |ip_address_changed| is set to true if we must report an IP address change. | |
62 // |dns_changed| is set to true if we must report a DNS config change. | |
63 void UpdateActiveNetwork(const chromeos::NetworkState* active_network, | |
stevenjb
2012/12/13 19:28:22
It looks like this doesn't actually do any updatin
gauravsh
2012/12/15 00:42:45
Changed this to UpdateState(), since it's changing
| |
64 bool* connection_type_changed, | |
65 bool* ip_address_changed, | |
66 bool* dns_changed); | |
67 | |
68 // Maps the shill network type and technology to its NetworkChangeNotifier | |
69 // equivalent. | |
70 static NetworkChangeNotifier::ConnectionType | |
71 ConnectionTypeFromShill(const std::string& type, | |
72 const std::string& technology); | |
73 | |
74 // Calculates parameters used for network change notifier online/offline | |
75 // signals. | |
76 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsChromeos(); | |
77 | |
78 NetworkChangeNotifier::ConnectionType connection_type_; | |
stevenjb
2012/12/13 19:28:22
We should be consistent with whether or not we use
gauravsh
2012/12/15 00:42:45
Made it consistent. I prefer the qualifier because
| |
79 // IP address for the current active network. | |
80 std::string ip_address_; | |
81 // Service path for the current active network. | |
82 std::string service_path_; | |
83 | |
84 scoped_ptr<DnsConfigService> dns_config_service_; | |
85 | |
86 FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest, | |
87 ConnectionTypeFromShill); | |
stevenjb
2012/12/13 19:28:22
FRIEND* should be just below private
gauravsh
2012/12/15 00:42:45
Done.
| |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos); | |
90 }; | |
91 | |
92 } // namespace chromeos | |
93 | |
94 #endif // CHROMEOS_CONNECTION_CHANGE_NOTIFIER_H_ | |
OLD | NEW |