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

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, 5 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 GetCurrentWifiAccessPointInfo(WifiAccessPointInfo *info)
Ilya Sherman 2014/07/11 01:32:17 nit: Swap position of space and asterisk.
zqiu1 2014/07/14 17:21:57 Done.
40 OVERRIDE;
37 41
38 // PowerManagerClient::Observer overrides. 42 // PowerManagerClient::Observer overrides.
39 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; 43 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE;
40 44
41 // NetworkStateHandlerObserver overrides. 45 // NetworkStateHandlerObserver overrides.
42 virtual void DefaultNetworkChanged( 46 virtual void DefaultNetworkChanged(
43 const chromeos::NetworkState* default_network) OVERRIDE; 47 const chromeos::NetworkState* default_network) OVERRIDE;
44 48
45 private: 49 private:
46 FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest, 50 FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest,
47 ConnectionTypeFromShill); 51 ConnectionTypeFromShill);
48 friend class NetworkChangeNotifierChromeosUpdateTest; 52 friend class NetworkChangeNotifierChromeosUpdateTest;
49 53
50 class DnsConfigService; 54 class DnsConfigService;
51 55
52 // Updates the notifier state based on a default network update. 56 // Updates the notifier state based on a default network update.
53 // |connection_type_changed| is set to true if we must report a connection 57 // |connection_type_changed| is set to true if we must report a connection
54 // type change. 58 // type change.
55 // |ip_address_changed| is set to true if we must report an IP address change. 59 // |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. 60 // |dns_changed| is set to true if we must report a DNS config change.
57 void UpdateState(const chromeos::NetworkState* default_network, 61 void UpdateState(const chromeos::NetworkState* default_network,
58 bool* connection_type_changed, 62 bool* connection_type_changed,
59 bool* ip_address_changed, 63 bool* ip_address_changed,
60 bool* dns_changed); 64 bool* dns_changed);
61 65
66 // Callback from Shill.Service.GetProperties. Parses |properties| to obtain
67 // the wifi access point information.
68 void ParseWifiAccessPointInfo(const std::string& service_path,
69 const base::DictionaryValue& properties);
70
62 // Maps the shill network type and technology to its NetworkChangeNotifier 71 // Maps the shill network type and technology to its NetworkChangeNotifier
63 // equivalent. 72 // equivalent.
64 static net::NetworkChangeNotifier::ConnectionType 73 static net::NetworkChangeNotifier::ConnectionType
65 ConnectionTypeFromShill(const std::string& type, 74 ConnectionTypeFromShill(const std::string& type,
66 const std::string& technology); 75 const std::string& technology);
67 76
68 // Calculates parameters used for network change notifier online/offline 77 // Calculates parameters used for network change notifier online/offline
69 // signals. 78 // signals.
70 static net::NetworkChangeNotifier::NetworkChangeCalculatorParams 79 static net::NetworkChangeNotifier::NetworkChangeCalculatorParams
71 NetworkChangeCalculatorParamsChromeos(); 80 NetworkChangeCalculatorParamsChromeos();
72 81
73 NetworkChangeNotifier::ConnectionType connection_type_; 82 NetworkChangeNotifier::ConnectionType connection_type_;
83 // Wifi access point info.
84 NetworkChangeNotifier::WifiAccessPointInfo wifi_ap_info_;
74 // IP address for the current default network. 85 // IP address for the current default network.
75 std::string ip_address_; 86 std::string ip_address_;
76 // DNS servers for the current default network. 87 // DNS servers for the current default network.
77 std::vector<std::string> dns_servers_; 88 std::vector<std::string> dns_servers_;
78 // Service path for the current default network. 89 // Service path for the current default network.
79 std::string service_path_; 90 std::string service_path_;
80 91
81 scoped_ptr<DnsConfigService> dns_config_service_; 92 scoped_ptr<DnsConfigService> dns_config_service_;
82 93
83 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos); 94 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos);
84 }; 95 };
85 96
86 } // namespace chromeos 97 } // namespace chromeos
87 98
88 #endif // CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_ 99 #endif // CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698