Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chromeos/network/network_change_notifier_chromeos.h

Issue 328793002: Add wifi AP info to system profile metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_ 5 #ifndef CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
6 #define CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_ 6 #define CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
13 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/power_manager_client.h" 15 #include "chromeos/dbus/power_manager_client.h"
15 #include "chromeos/network/network_state_handler_observer.h" 16 #include "chromeos/network/network_state_handler_observer.h"
16 #include "net/base/network_change_notifier.h" 17 #include "net/base/network_change_notifier.h"
17 18
18 namespace chromeos { 19 namespace chromeos {
19 20
20 class CHROMEOS_EXPORT NetworkChangeNotifierChromeos 21 class CHROMEOS_EXPORT NetworkChangeNotifierChromeos
21 : public net::NetworkChangeNotifier, 22 : public net::NetworkChangeNotifier,
22 public chromeos::PowerManagerClient::Observer, 23 public chromeos::PowerManagerClient::Observer,
23 public chromeos::NetworkStateHandlerObserver { 24 public chromeos::NetworkStateHandlerObserver,
25 public base::SupportsWeakPtr<NetworkChangeNotifierChromeos> {
24 public: 26 public:
25 NetworkChangeNotifierChromeos(); 27 NetworkChangeNotifierChromeos();
26 virtual ~NetworkChangeNotifierChromeos(); 28 virtual ~NetworkChangeNotifierChromeos();
27 29
28 // Starts observing changes from the network state handler. 30 // Starts observing changes from the network state handler.
29 void Initialize(); 31 void Initialize();
30 32
31 // Stops observing changes from the network state handler. 33 // Stops observing changes from the network state handler.
32 void Shutdown(); 34 void Shutdown();
33 35
34 // NetworkChangeNotifier overrides. 36 // NetworkChangeNotifier overrides.
35 virtual net::NetworkChangeNotifier::ConnectionType 37 virtual net::NetworkChangeNotifier::ConnectionType
36 GetCurrentConnectionType() const OVERRIDE; 38 GetCurrentConnectionType() const OVERRIDE;
39 virtual bool GetCurrentWifiApInfo(WifiApInfo &info) OVERRIDE;
37 40
38 // PowerManagerClient::Observer overrides. 41 // PowerManagerClient::Observer overrides.
39 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; 42 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE;
40 43
41 // NetworkStateHandlerObserver overrides. 44 // NetworkStateHandlerObserver overrides.
42 virtual void DefaultNetworkChanged( 45 virtual void DefaultNetworkChanged(
43 const chromeos::NetworkState* default_network) OVERRIDE; 46 const chromeos::NetworkState* default_network) OVERRIDE;
44 47
45 private: 48 private:
46 FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest, 49 FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest,
47 ConnectionTypeFromShill); 50 ConnectionTypeFromShill);
48 friend class NetworkChangeNotifierChromeosUpdateTest; 51 friend class NetworkChangeNotifierChromeosUpdateTest;
49 52
50 class DnsConfigService; 53 class DnsConfigService;
51 54
52 // Updates the notifier state based on a default network update. 55 // Updates the notifier state based on a default network update.
53 // |connection_type_changed| is set to true if we must report a connection 56 // |connection_type_changed| is set to true if we must report a connection
54 // type change. 57 // type change.
55 // |ip_address_changed| is set to true if we must report an IP address change. 58 // |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. 59 // |dns_changed| is set to true if we must report a DNS config change.
57 void UpdateState(const chromeos::NetworkState* default_network, 60 void UpdateState(const chromeos::NetworkState* default_network,
58 bool* connection_type_changed, 61 bool* connection_type_changed,
59 bool* ip_address_changed, 62 bool* ip_address_changed,
60 bool* dns_changed); 63 bool* dns_changed);
61 64
65 // Callback from Shill.Service.GetProperties. Parses |properties| to obtain
66 // the wifi AP information.
67 void ParseWifiApInfo(const std::string& service_path,
68 const base::DictionaryValue& properties);
69
70 // Error callback from Shill.Service.GetProperties, most likely the network
71 // service is removed before the properties can be retrieved.
72 void GetPropertiesFailedHandler(
73 const std::string& error_name,
74 scoped_ptr<base::DictionaryValue> error_data);
75
62 // Maps the shill network type and technology to its NetworkChangeNotifier 76 // Maps the shill network type and technology to its NetworkChangeNotifier
63 // equivalent. 77 // equivalent.
64 static net::NetworkChangeNotifier::ConnectionType 78 static net::NetworkChangeNotifier::ConnectionType
65 ConnectionTypeFromShill(const std::string& type, 79 ConnectionTypeFromShill(const std::string& type,
66 const std::string& technology); 80 const std::string& technology);
67 81
68 // Calculates parameters used for network change notifier online/offline 82 // Calculates parameters used for network change notifier online/offline
69 // signals. 83 // signals.
70 static net::NetworkChangeNotifier::NetworkChangeCalculatorParams 84 static net::NetworkChangeNotifier::NetworkChangeCalculatorParams
71 NetworkChangeCalculatorParamsChromeos(); 85 NetworkChangeCalculatorParamsChromeos();
72 86
73 NetworkChangeNotifier::ConnectionType connection_type_; 87 NetworkChangeNotifier::ConnectionType connection_type_;
88 // Wifi AP info.
89 NetworkChangeNotifier::WifiApInfo wifi_ap_info_;
74 // IP address for the current default network. 90 // IP address for the current default network.
75 std::string ip_address_; 91 std::string ip_address_;
76 // DNS servers for the current default network. 92 // DNS servers for the current default network.
77 std::vector<std::string> dns_servers_; 93 std::vector<std::string> dns_servers_;
78 // Service path for the current default network. 94 // Service path for the current default network.
79 std::string service_path_; 95 std::string service_path_;
80 96
81 scoped_ptr<DnsConfigService> dns_config_service_; 97 scoped_ptr<DnsConfigService> dns_config_service_;
82 98
83 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos); 99 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos);
84 }; 100 };
85 101
86 } // namespace chromeos 102 } // namespace chromeos
87 103
88 #endif // CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_ 104 #endif // CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698