OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 NetworkDevice::~NetworkDevice() {} | 172 NetworkDevice::~NetworkDevice() {} |
173 | 173 |
174 void NetworkDevice::ParseInfo(const DictionaryValue& info) { | 174 void NetworkDevice::ParseInfo(const DictionaryValue& info) { |
175 if (device_parser_.get()) | 175 if (device_parser_.get()) |
176 device_parser_->UpdateDeviceFromInfo(info, this); | 176 device_parser_->UpdateDeviceFromInfo(info, this); |
177 } | 177 } |
178 | 178 |
179 bool NetworkDevice::UpdateStatus(const std::string& key, | 179 bool NetworkDevice::UpdateStatus(const std::string& key, |
180 const Value& value, | 180 Value* value, |
181 PropertyIndex* index) { | 181 PropertyIndex* index) { |
182 if (device_parser_.get()) | 182 if (device_parser_.get()) |
183 return device_parser_->UpdateStatus(key, value, this, index); | 183 return device_parser_->UpdateStatus(key, value, this, index); |
184 return false; | 184 return false; |
185 } | 185 } |
186 | 186 |
187 //////////////////////////////////////////////////////////////////////////////// | 187 //////////////////////////////////////////////////////////////////////////////// |
188 // Network | 188 // Network |
189 | 189 |
190 Network::Network(const std::string& service_path, | 190 Network::Network(const std::string& service_path, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 ip_address_ = ipconfig.address; | 417 ip_address_ = ipconfig.address; |
418 break; | 418 break; |
419 } | 419 } |
420 } | 420 } |
421 chromeos::FreeIPConfigStatus(ipconfig_status); | 421 chromeos::FreeIPConfigStatus(ipconfig_status); |
422 } | 422 } |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 bool Network::UpdateStatus(const std::string& key, | 426 bool Network::UpdateStatus(const std::string& key, |
427 const Value& value, | 427 Value* value, |
428 PropertyIndex* index) { | 428 PropertyIndex* index) { |
429 if (network_parser_.get()) | 429 if (network_parser_.get()) |
430 return network_parser_->UpdateStatus(key, value, this, index); | 430 return network_parser_->UpdateStatus(key, value, this, index); |
431 return false; | 431 return false; |
432 } | 432 } |
433 | 433 |
434 //////////////////////////////////////////////////////////////////////////////// | 434 //////////////////////////////////////////////////////////////////////////////// |
435 // EthernetNetwork | 435 // EthernetNetwork |
436 | 436 |
437 EthernetNetwork::EthernetNetwork(const std::string& service_path) | 437 EthernetNetwork::EthernetNetwork(const std::string& service_path) |
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 virtual NetworkIPConfigVector GetIPConfigs( | 2966 virtual NetworkIPConfigVector GetIPConfigs( |
2967 const std::string& device_path, | 2967 const std::string& device_path, |
2968 std::string* hardware_address, | 2968 std::string* hardware_address, |
2969 HardwareAddressFormat format) OVERRIDE; | 2969 HardwareAddressFormat format) OVERRIDE; |
2970 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) OVERRIDE; | 2970 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) OVERRIDE; |
2971 | 2971 |
2972 ////////////////////////////////////////////////////////////////////////////// | 2972 ////////////////////////////////////////////////////////////////////////////// |
2973 // Calbacks. | 2973 // Calbacks. |
2974 static void NetworkStatusChangedHandler( | 2974 static void NetworkStatusChangedHandler( |
2975 void* object, const char* path, const char* key, const Value* value); | 2975 void* object, const char* path, const char* key, const Value* value); |
2976 void UpdateNetworkStatus( | 2976 void UpdateNetworkStatus(const std::string& path, |
2977 const std::string& path, const std::string& key, const Value& value); | 2977 const std::string& key, |
| 2978 Value* value); |
2978 | 2979 |
2979 static void NetworkDevicePropertyChangedHandler( | 2980 static void NetworkDevicePropertyChangedHandler( |
2980 void* object, const char* path, const char* key, const Value* value); | 2981 void* object, const char* path, const char* key, const Value* value); |
2981 void UpdateNetworkDeviceStatus( | 2982 void UpdateNetworkDeviceStatus( |
2982 const std::string& path, const std::string& key, const Value& value); | 2983 const std::string& path, const std::string& key, Value* value); |
2983 | 2984 |
2984 static void PinOperationCallback(void* object, | 2985 static void PinOperationCallback(void* object, |
2985 const char* path, | 2986 const char* path, |
2986 NetworkMethodErrorType error, | 2987 NetworkMethodErrorType error, |
2987 const char* error_message); | 2988 const char* error_message); |
2988 | 2989 |
2989 static void CellularRegisterCallback(void* object, | 2990 static void CellularRegisterCallback(void* object, |
2990 const char* path, | 2991 const char* path, |
2991 NetworkMethodErrorType error, | 2992 NetworkMethodErrorType error, |
2992 const char* error_message); | 2993 const char* error_message); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 } | 3160 } |
3160 | 3161 |
3161 // static callback | 3162 // static callback |
3162 void NetworkLibraryImplCros::NetworkStatusChangedHandler( | 3163 void NetworkLibraryImplCros::NetworkStatusChangedHandler( |
3163 void* object, const char* path, const char* key, const Value* value) { | 3164 void* object, const char* path, const char* key, const Value* value) { |
3164 NetworkLibraryImplCros* networklib = | 3165 NetworkLibraryImplCros* networklib = |
3165 static_cast<NetworkLibraryImplCros*>(object); | 3166 static_cast<NetworkLibraryImplCros*>(object); |
3166 DCHECK(networklib); | 3167 DCHECK(networklib); |
3167 if (key == NULL || value == NULL || path == NULL || object == NULL) | 3168 if (key == NULL || value == NULL || path == NULL || object == NULL) |
3168 return; | 3169 return; |
3169 networklib->UpdateNetworkStatus(std::string(path), std::string(key), *value); | 3170 networklib->UpdateNetworkStatus(std::string(path), |
| 3171 std::string(key), |
| 3172 const_cast<Value*>(value)); |
3170 } | 3173 } |
3171 | 3174 |
3172 void NetworkLibraryImplCros::UpdateNetworkStatus( | 3175 void NetworkLibraryImplCros::UpdateNetworkStatus(const std::string& path, |
3173 const std::string& path, const std::string& key, const Value& value) { | 3176 const std::string& key, |
| 3177 Value* value) { |
3174 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3178 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
3175 Network* network = FindNetworkByPath(path); | 3179 Network* network = FindNetworkByPath(path); |
3176 if (network) { | 3180 if (network) { |
3177 VLOG(2) << "UpdateNetworkStatus: " << network->name() << "." << key; | 3181 VLOG(2) << "UpdateNetworkStatus: " << network->name() << "." << key; |
3178 bool prev_connected = network->connected(); | 3182 bool prev_connected = network->connected(); |
3179 if (!network->UpdateStatus(key, value, NULL)) { | 3183 if (!network->UpdateStatus(key, value, NULL)) { |
3180 LOG(WARNING) << "UpdateNetworkStatus: Error updating: " | 3184 LOG(WARNING) << "UpdateNetworkStatus: Error updating: " |
3181 << path << "." << key; | 3185 << path << "." << key; |
3182 } | 3186 } |
3183 // If we just connected, this may have been added to remembered list. | 3187 // If we just connected, this may have been added to remembered list. |
3184 if (!prev_connected && network->connected()) | 3188 if (!prev_connected && network->connected()) |
3185 RequestRememberedNetworksUpdate(); | 3189 RequestRememberedNetworksUpdate(); |
3186 NotifyNetworkChanged(network); | 3190 NotifyNetworkChanged(network); |
3187 // Anything observing the manager needs to know about any service change. | 3191 // Anything observing the manager needs to know about any service change. |
3188 NotifyNetworkManagerChanged(false); // Not forced. | 3192 NotifyNetworkManagerChanged(false); // Not forced. |
3189 } | 3193 } |
3190 } | 3194 } |
3191 | 3195 |
3192 // static callback | 3196 // static callback |
3193 void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler( | 3197 void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler( |
3194 void* object, const char* path, const char* key, const Value* value) { | 3198 void* object, const char* path, const char* key, const Value* value) { |
3195 NetworkLibraryImplCros* networklib = | 3199 NetworkLibraryImplCros* networklib = |
3196 static_cast<NetworkLibraryImplCros*>(object); | 3200 static_cast<NetworkLibraryImplCros*>(object); |
3197 DCHECK(networklib); | 3201 DCHECK(networklib); |
3198 if (key == NULL || value == NULL || path == NULL || object == NULL) | 3202 if (key == NULL || value == NULL || path == NULL || object == NULL) |
3199 return; | 3203 return; |
3200 networklib->UpdateNetworkDeviceStatus(std::string(path), | 3204 networklib->UpdateNetworkDeviceStatus(std::string(path), |
3201 std::string(key), | 3205 std::string(key), |
3202 *value); | 3206 const_cast<Value*>(value)); |
3203 } | 3207 } |
3204 | 3208 |
3205 void NetworkLibraryImplCros::UpdateNetworkDeviceStatus( | 3209 void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(const std::string& path, |
3206 const std::string& path, const std::string& key, const Value& value) { | 3210 const std::string& key, |
| 3211 Value* value) { |
3207 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3212 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
3208 NetworkDevice* device = FindNetworkDeviceByPath(path); | 3213 NetworkDevice* device = FindNetworkDeviceByPath(path); |
3209 if (device) { | 3214 if (device) { |
3210 VLOG(2) << "UpdateNetworkDeviceStatus: " << device->name() << "." << key; | 3215 VLOG(2) << "UpdateNetworkDeviceStatus: " << device->name() << "." << key; |
3211 PropertyIndex index = PROPERTY_INDEX_UNKNOWN; | 3216 PropertyIndex index = PROPERTY_INDEX_UNKNOWN; |
3212 if (device->UpdateStatus(key, value, &index)) { | 3217 if (device->UpdateStatus(key, value, &index)) { |
3213 if (index == PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING) { | 3218 if (index == PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING) { |
3214 bool settings_value = | 3219 bool settings_value = |
3215 UserCrosSettingsProvider::cached_data_roaming_enabled(); | 3220 UserCrosSettingsProvider::cached_data_roaming_enabled(); |
3216 if (device->data_roaming_allowed() != settings_value) { | 3221 if (device->data_roaming_allowed() != settings_value) { |
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4612 return network_library; | 4617 return network_library; |
4613 } | 4618 } |
4614 | 4619 |
4615 ///////////////////////////////////////////////////////////////////////////// | 4620 ///////////////////////////////////////////////////////////////////////////// |
4616 | 4621 |
4617 } // namespace chromeos | 4622 } // namespace chromeos |
4618 | 4623 |
4619 // Allows InvokeLater without adding refcounting. This class is a Singleton and | 4624 // Allows InvokeLater without adding refcounting. This class is a Singleton and |
4620 // won't be deleted until its last InvokeLater is run. | 4625 // won't be deleted until its last InvokeLater is run. |
4621 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); | 4626 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); |
OLD | NEW |