Some additional network settings cleanup
[chromium-blink-merge.git] / chromeos / network / network_change_notifier_chromeos.h
blobd70386e168c509d8aa28987960e1e0394dece442
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.
5 #ifndef CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
6 #define CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/power_manager_client.h"
15 #include "chromeos/network/network_state_handler_observer.h"
16 #include "net/base/network_change_notifier.h"
18 namespace chromeos {
20 class CHROMEOS_EXPORT NetworkChangeNotifierChromeos
21 : public net::NetworkChangeNotifier,
22 public chromeos::PowerManagerClient::Observer,
23 public chromeos::NetworkStateHandlerObserver {
24 public:
25 NetworkChangeNotifierChromeos();
26 virtual ~NetworkChangeNotifierChromeos();
28 // Starts observing changes from the network state handler.
29 void Initialize();
31 // Stops observing changes from the network state handler.
32 void Shutdown();
34 // NetworkChangeNotifier overrides.
35 virtual net::NetworkChangeNotifier::ConnectionType
36 GetCurrentConnectionType() const OVERRIDE;
38 // PowerManagerClient::Observer overrides.
39 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE;
41 // NetworkStateHandlerObserver overrides.
42 virtual void DefaultNetworkChanged(
43 const chromeos::NetworkState* default_network) OVERRIDE;
45 private:
46 FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest,
47 ConnectionTypeFromShill);
48 friend class NetworkChangeNotifierChromeosUpdateTest;
50 class DnsConfigService;
52 // Updates the notifier state based on a default network update.
53 // |connection_type_changed| is set to true if we must report a connection
54 // type change.
55 // |ip_address_changed| is set to true if we must report an IP address change.
56 // |dns_changed| is set to true if we must report a DNS config change.
57 void UpdateState(const chromeos::NetworkState* default_network,
58 bool* connection_type_changed,
59 bool* ip_address_changed,
60 bool* dns_changed);
62 // Maps the shill network type and technology to its NetworkChangeNotifier
63 // equivalent.
64 static net::NetworkChangeNotifier::ConnectionType
65 ConnectionTypeFromShill(const std::string& type,
66 const std::string& technology);
68 // Calculates parameters used for network change notifier online/offline
69 // signals.
70 static net::NetworkChangeNotifier::NetworkChangeCalculatorParams
71 NetworkChangeCalculatorParamsChromeos();
73 NetworkChangeNotifier::ConnectionType connection_type_;
74 // IP address for the current default network.
75 std::string ip_address_;
76 // DNS servers for the current default network.
77 std::vector<std::string> dns_servers_;
78 // Service path for the current default network.
79 std::string service_path_;
81 scoped_ptr<DnsConfigService> dns_config_service_;
83 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos);
86 } // namespace chromeos
88 #endif // CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_