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

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

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 #include <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "chromeos/network/network_change_notifier_chromeos.h" 12 #include "chromeos/network/network_change_notifier_chromeos.h"
13 #include "chromeos/network/network_configuration_handler.h"
13 #include "chromeos/network/network_event_log.h" 14 #include "chromeos/network/network_event_log.h"
14 #include "chromeos/network/network_state.h" 15 #include "chromeos/network/network_state.h"
15 #include "chromeos/network/network_state_handler.h" 16 #include "chromeos/network/network_state_handler.h"
16 #include "net/base/network_change_notifier.h" 17 #include "net/base/network_change_notifier.h"
17 #include "net/dns/dns_config_service_posix.h" 18 #include "net/dns/dns_config_service_posix.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
19 20
20 namespace chromeos { 21 namespace chromeos {
21 22
22 // DNS config services on Chrome OS are signalled by the network state handler 23 // DNS config services on Chrome OS are signalled by the network state handler
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 NetworkHandler::Get()->network_state_handler()->RemoveObserver( 77 NetworkHandler::Get()->network_state_handler()->RemoveObserver(
77 this, FROM_HERE); 78 this, FROM_HERE);
78 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); 79 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
79 } 80 }
80 81
81 net::NetworkChangeNotifier::ConnectionType 82 net::NetworkChangeNotifier::ConnectionType
82 NetworkChangeNotifierChromeos::GetCurrentConnectionType() const { 83 NetworkChangeNotifierChromeos::GetCurrentConnectionType() const {
83 return connection_type_; 84 return connection_type_;
84 } 85 }
85 86
87 bool NetworkChangeNotifierChromeos::GetCurrentWifiApInfo(
88 net::NetworkChangeNotifier::WifiApInfo &info) {
89 if (connection_type_ != CONNECTION_WIFI) {
90 return false;
91 }
stevenjb 2014/06/12 20:54:40 nit: {} unnecessary.
zqiu1 2014/07/07 23:37:33 Done.
92
93 info = wifi_ap_info_;
94 return true;
95 }
96
86 void NetworkChangeNotifierChromeos::SuspendDone( 97 void NetworkChangeNotifierChromeos::SuspendDone(
87 const base::TimeDelta& sleep_duration) { 98 const base::TimeDelta& sleep_duration) {
88 // Force invalidation of network resources on resume. 99 // Force invalidation of network resources on resume.
89 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); 100 NetworkChangeNotifier::NotifyObserversOfIPAddressChange();
90 } 101 }
91 102
92 103
93 void NetworkChangeNotifierChromeos::DefaultNetworkChanged( 104 void NetworkChangeNotifierChromeos::DefaultNetworkChanged(
94 const chromeos::NetworkState* default_network) { 105 const chromeos::NetworkState* default_network) {
95 bool connection_type_changed = false; 106 bool connection_type_changed = false;
96 bool ip_address_changed = false; 107 bool ip_address_changed = false;
97 bool dns_changed = false; 108 bool dns_changed = false;
98 109
99 UpdateState(default_network, &connection_type_changed, 110 UpdateState(default_network, &connection_type_changed,
100 &ip_address_changed, &dns_changed); 111 &ip_address_changed, &dns_changed);
101 112
102 if (connection_type_changed) 113 if (connection_type_changed)
103 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); 114 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange();
104 if (ip_address_changed) 115 if (ip_address_changed)
105 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); 116 NetworkChangeNotifier::NotifyObserversOfIPAddressChange();
106 if (dns_changed) 117 if (dns_changed)
107 dns_config_service_->OnNetworkChange(); 118 dns_config_service_->OnNetworkChange();
119
120 // Retrieve AP info for wifi connection.
121 if (connection_type_ == CONNECTION_WIFI) {
122 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
123 default_network->path(),
124 base::Bind(&NetworkChangeNotifierChromeos::ParseWifiApInfo,
125 AsWeakPtr()),
126 base::Bind(&NetworkChangeNotifierChromeos::GetPropertiesFailedHandler,
127 AsWeakPtr()));
128 }
129 }
130
131 void NetworkChangeNotifierChromeos::ParseWifiApInfo(
132 const std::string &service_path,
133 const base::DictionaryValue& properties) {
134 net::NetworkChangeNotifier::WifiApInfo info;
135 properties.GetStringWithoutPathExpansion(
136 shill::kWifiBSsid, &(info.bssid));
stevenjb 2014/06/12 20:54:40 nit: () after & unnecessary here and below
zqiu1 2014/07/07 23:37:33 Done.
137 properties.GetStringWithoutPathExpansion(
138 shill::kSecurityProperty, &(info.security));
139 const base::DictionaryValue* vendor_dict = NULL;
140 if (properties.GetDictionaryWithoutPathExpansion(
141 shill::kWifiVendorInformationProperty,
142 &vendor_dict)) {
143 vendor_dict->GetStringWithoutPathExpansion(
144 shill::kVendorWPSModelNumberProperty,
145 &(info.model_number));
146 vendor_dict->GetStringWithoutPathExpansion(
147 shill::kVendorWPSModelNameProperty,
148 &(info.model_name));
149 vendor_dict->GetStringWithoutPathExpansion(
150 shill::kVendorWPSDeviceNameProperty,
151 &(info.device_name));
152 vendor_dict->GetStringWithoutPathExpansion(
153 shill::kVendorWPSManufacturerProperty,
154 &(info.manufacturer));
155 vendor_dict->GetStringWithoutPathExpansion(shill::kVendorOUIListProperty,
156 &(info.oui_list));
157 }
158 wifi_ap_info_ = info;
159 }
160
161 void NetworkChangeNotifierChromeos::GetPropertiesFailedHandler(
162 const std::string& error_name,
163 scoped_ptr<base::DictionaryValue> error_data) {
164 // Nothing to be done, most likely the network service is already removed.
stevenjb 2014/06/12 20:54:40 Since this is a noop you can just pass network_han
zqiu1 2014/07/07 23:37:32 Done.
108 } 165 }
109 166
110 void NetworkChangeNotifierChromeos::UpdateState( 167 void NetworkChangeNotifierChromeos::UpdateState(
111 const chromeos::NetworkState* default_network, 168 const chromeos::NetworkState* default_network,
112 bool* connection_type_changed, 169 bool* connection_type_changed,
113 bool* ip_address_changed, 170 bool* ip_address_changed,
114 bool* dns_changed) { 171 bool* dns_changed) {
115 *connection_type_changed = false; 172 *connection_type_changed = false;
116 *ip_address_changed = false; 173 *ip_address_changed = false;
117 *dns_changed = false; 174 *dns_changed = false;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // produce a single signal when switching between network connections. 286 // produce a single signal when switching between network connections.
230 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); 287 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000);
231 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); 288 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000);
232 params.connection_type_offline_delay_ = 289 params.connection_type_offline_delay_ =
233 base::TimeDelta::FromMilliseconds(500); 290 base::TimeDelta::FromMilliseconds(500);
234 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500); 291 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500);
235 return params; 292 return params;
236 } 293 }
237 294
238 } // namespace chromeos 295 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698