Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/wifi/wifi_service.h" | 5 #include "components/wifi/wifi_service.h" |
| 6 | 6 |
| 7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
| 8 #include <objbase.h> | 8 #include <objbase.h> |
| 9 #include <wlanapi.h> | 9 #include <wlanapi.h> |
| 10 | 10 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 *error = kWiFiServiceError; | 699 *error = kWiFiServiceError; |
| 700 } | 700 } |
| 701 | 701 |
| 702 void WiFiServiceImpl::SetEventObservers( | 702 void WiFiServiceImpl::SetEventObservers( |
| 703 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 703 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
| 704 const NetworkGuidListCallback& networks_changed_observer, | 704 const NetworkGuidListCallback& networks_changed_observer, |
| 705 const NetworkGuidListCallback& network_list_changed_observer) { | 705 const NetworkGuidListCallback& network_list_changed_observer) { |
| 706 message_loop_proxy_.swap(message_loop_proxy); | 706 message_loop_proxy_.swap(message_loop_proxy); |
| 707 networks_changed_observer_ = networks_changed_observer; | 707 networks_changed_observer_ = networks_changed_observer; |
| 708 network_list_changed_observer_ = network_list_changed_observer; | 708 network_list_changed_observer_ = network_list_changed_observer; |
| 709 // Start listening to WLAN notifications. | |
| 710 WlanRegisterNotification_function_(client_, | |
|
tbarzic
2014/02/25 20:40:49
Should this be protected from multiple |SetEventOb
mef
2014/02/25 22:36:26
Done.
| |
| 711 WLAN_NOTIFICATION_SOURCE_ALL, | |
| 712 FALSE, | |
| 713 OnWlanNotificationCallback, | |
| 714 this, | |
| 715 NULL, | |
| 716 NULL); | |
| 709 } | 717 } |
| 710 | 718 |
| 711 void WiFiServiceImpl::OnWlanNotificationCallback( | 719 void WiFiServiceImpl::OnWlanNotificationCallback( |
| 712 PWLAN_NOTIFICATION_DATA wlan_notification_data, | 720 PWLAN_NOTIFICATION_DATA wlan_notification_data, |
| 713 PVOID context) { | 721 PVOID context) { |
| 714 WiFiServiceImpl* service = reinterpret_cast<WiFiServiceImpl*>(context); | 722 WiFiServiceImpl* service = reinterpret_cast<WiFiServiceImpl*>(context); |
| 715 service->OnWlanNotification(wlan_notification_data); | 723 service->OnWlanNotification(wlan_notification_data); |
| 716 } | 724 } |
| 717 | 725 |
| 718 void WiFiServiceImpl::OnWlanNotification( | 726 void WiFiServiceImpl::OnWlanNotification( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 936 interface_guid_ = interface_list->InterfaceInfo[0].InterfaceGuid; | 944 interface_guid_ = interface_list->InterfaceInfo[0].InterfaceGuid; |
| 937 // Try to find a connected interface. | 945 // Try to find a connected interface. |
| 938 for (DWORD itf = 0; itf < interface_list->dwNumberOfItems; ++itf) { | 946 for (DWORD itf = 0; itf < interface_list->dwNumberOfItems; ++itf) { |
| 939 if (interface_list->InterfaceInfo[itf].isState == | 947 if (interface_list->InterfaceInfo[itf].isState == |
| 940 wlan_interface_state_connected) { | 948 wlan_interface_state_connected) { |
| 941 // Found connected interface, remember it! | 949 // Found connected interface, remember it! |
| 942 interface_guid_ = interface_list->InterfaceInfo[itf].InterfaceGuid; | 950 interface_guid_ = interface_list->InterfaceInfo[itf].InterfaceGuid; |
| 943 break; | 951 break; |
| 944 } | 952 } |
| 945 } | 953 } |
| 946 WlanRegisterNotification_function_(client_, | |
| 947 WLAN_NOTIFICATION_SOURCE_ALL, | |
| 948 FALSE, | |
| 949 OnWlanNotificationCallback, | |
| 950 this, | |
| 951 NULL, | |
| 952 NULL); | |
| 953 } else { | 954 } else { |
| 954 error = ERROR_NOINTERFACE; | 955 error = ERROR_NOINTERFACE; |
| 955 } | 956 } |
| 956 } | 957 } |
| 957 // Clean up.. | 958 // Clean up.. |
| 958 if (interface_list != NULL) | 959 if (interface_list != NULL) |
| 959 WlanFreeMemory_function_(interface_list); | 960 WlanFreeMemory_function_(interface_list); |
| 960 } | 961 } |
| 961 return error; | 962 return error; |
| 962 } | 963 } |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1644 NetworkGuidList changed_networks(1, network_guid); | 1645 NetworkGuidList changed_networks(1, network_guid); |
| 1645 message_loop_proxy_->PostTask( | 1646 message_loop_proxy_->PostTask( |
| 1646 FROM_HERE, | 1647 FROM_HERE, |
| 1647 base::Bind(networks_changed_observer_, changed_networks)); | 1648 base::Bind(networks_changed_observer_, changed_networks)); |
| 1648 } | 1649 } |
| 1649 } | 1650 } |
| 1650 | 1651 |
| 1651 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } | 1652 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } |
| 1652 | 1653 |
| 1653 } // namespace wifi | 1654 } // namespace wifi |
| OLD | NEW |