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

Side by Side Diff: components/wifi/wifi_service_win.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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
« no previous file with comments | « components/wifi/wifi_service_mac.mm ('k') | components/wifi/wifi_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 std::string* error) override; 213 std::string* error) override;
214 214
215 void StartDisconnect(const std::string& network_guid, 215 void StartDisconnect(const std::string& network_guid,
216 std::string* error) override; 216 std::string* error) override;
217 217
218 void GetKeyFromSystem(const std::string& network_guid, 218 void GetKeyFromSystem(const std::string& network_guid,
219 std::string* key_data, 219 std::string* key_data,
220 std::string* error) override; 220 std::string* error) override;
221 221
222 void SetEventObservers( 222 void SetEventObservers(
223 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 223 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
224 const NetworkGuidListCallback& networks_changed_observer, 224 const NetworkGuidListCallback& networks_changed_observer,
225 const NetworkGuidListCallback& network_list_changed_observer) override; 225 const NetworkGuidListCallback& network_list_changed_observer) override;
226 226
227 void RequestConnectedNetworkUpdate() override {} 227 void RequestConnectedNetworkUpdate() override {}
228 228
229 void GetConnectedNetworkSSID(std::string* ssid, std::string* error) override; 229 void GetConnectedNetworkSSID(std::string* ssid, std::string* error) override;
230 230
231 private: 231 private:
232 typedef int32 EncryptionType; 232 typedef int32 EncryptionType;
233 enum EncryptionTypeEnum { 233 enum EncryptionTypeEnum {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // encryption type saved by |CreateNetwork| if applicable. Profile has to be 458 // encryption type saved by |CreateNetwork| if applicable. Profile has to be
459 // deleted if connection fails. Implicitly created profiles have to be deleted 459 // deleted if connection fails. Implicitly created profiles have to be deleted
460 // if connection succeeds. Persist only in memory. 460 // if connection succeeds. Persist only in memory.
461 base::DictionaryValue created_profiles_; 461 base::DictionaryValue created_profiles_;
462 // Observer to get notified when network(s) have changed (e.g. connect). 462 // Observer to get notified when network(s) have changed (e.g. connect).
463 NetworkGuidListCallback networks_changed_observer_; 463 NetworkGuidListCallback networks_changed_observer_;
464 // Observer to get notified when network list has changed (scan complete). 464 // Observer to get notified when network list has changed (scan complete).
465 NetworkGuidListCallback network_list_changed_observer_; 465 NetworkGuidListCallback network_list_changed_observer_;
466 // Saved value of network location wizard show value. 466 // Saved value of network location wizard show value.
467 scoped_ptr<DWORD> saved_nw_category_wizard_; 467 scoped_ptr<DWORD> saved_nw_category_wizard_;
468 // MessageLoopProxy to post events on UI thread. 468 // Task runner to post events on UI thread.
469 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 469 scoped_refptr<base::SingleThreadTaskRunner> event_task_runner_;
470 // Task runner for worker tasks. 470 // Task runner for worker tasks.
471 scoped_refptr<base::SequencedTaskRunner> task_runner_; 471 scoped_refptr<base::SequencedTaskRunner> task_runner_;
472 // If |false|, then |networks_changed_observer_| is not notified. 472 // If |false|, then |networks_changed_observer_| is not notified.
473 bool enable_notify_network_changed_; 473 bool enable_notify_network_changed_;
474 // Number of attempts to check that network has connected successfully. 474 // Number of attempts to check that network has connected successfully.
475 static const int kMaxAttempts = 100; 475 static const int kMaxAttempts = 100;
476 // Delay between attempts to check that network has connected successfully. 476 // Delay between attempts to check that network has connected successfully.
477 static const int kAttemptDelayMs = 100; 477 static const int kAttemptDelayMs = 100;
478 DISALLOW_COPY_AND_ASSIGN(WiFiServiceImpl); 478 DISALLOW_COPY_AND_ASSIGN(WiFiServiceImpl);
479 }; 479 };
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 return; 773 return;
774 } 774 }
775 } 775 }
776 } 776 }
777 777
778 // Did not find passphrase in the profile. 778 // Did not find passphrase in the profile.
779 *error = kErrorWiFiService; 779 *error = kErrorWiFiService;
780 } 780 }
781 781
782 void WiFiServiceImpl::SetEventObservers( 782 void WiFiServiceImpl::SetEventObservers(
783 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 783 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
784 const NetworkGuidListCallback& networks_changed_observer, 784 const NetworkGuidListCallback& networks_changed_observer,
785 const NetworkGuidListCallback& network_list_changed_observer) { 785 const NetworkGuidListCallback& network_list_changed_observer) {
786 DWORD error_code = EnsureInitialized(); 786 DWORD error_code = EnsureInitialized();
787 if (error_code != ERROR_SUCCESS) 787 if (error_code != ERROR_SUCCESS)
788 return; 788 return;
789 message_loop_proxy_.swap(message_loop_proxy); 789 event_task_runner_.swap(task_runner);
790 if (!networks_changed_observer_.is_null() || 790 if (!networks_changed_observer_.is_null() ||
791 !network_list_changed_observer_.is_null()) { 791 !network_list_changed_observer_.is_null()) {
792 // Stop listening to WLAN notifications. 792 // Stop listening to WLAN notifications.
793 WlanRegisterNotification_function_(client_, 793 WlanRegisterNotification_function_(client_,
794 WLAN_NOTIFICATION_SOURCE_NONE, 794 WLAN_NOTIFICATION_SOURCE_NONE,
795 FALSE, 795 FALSE,
796 OnWlanNotificationCallback, 796 OnWlanNotificationCallback,
797 this, 797 this,
798 NULL, 798 NULL,
799 NULL); 799 NULL);
(...skipping 27 matching lines...) Expand all
827 827
828 void WiFiServiceImpl::OnWlanNotificationCallback( 828 void WiFiServiceImpl::OnWlanNotificationCallback(
829 PWLAN_NOTIFICATION_DATA wlan_notification_data, 829 PWLAN_NOTIFICATION_DATA wlan_notification_data,
830 PVOID context) { 830 PVOID context) {
831 WiFiServiceImpl* service = reinterpret_cast<WiFiServiceImpl*>(context); 831 WiFiServiceImpl* service = reinterpret_cast<WiFiServiceImpl*>(context);
832 service->OnWlanNotification(wlan_notification_data); 832 service->OnWlanNotification(wlan_notification_data);
833 } 833 }
834 834
835 void WiFiServiceImpl::OnWlanNotification( 835 void WiFiServiceImpl::OnWlanNotification(
836 PWLAN_NOTIFICATION_DATA wlan_notification_data) { 836 PWLAN_NOTIFICATION_DATA wlan_notification_data) {
837 if (message_loop_proxy_.get() == NULL) 837 if (event_task_runner_.get() == NULL)
838 return; 838 return;
839 switch (wlan_notification_data->NotificationCode) { 839 switch (wlan_notification_data->NotificationCode) {
840 case wlan_notification_acm_disconnected: 840 case wlan_notification_acm_disconnected:
841 case wlan_notification_acm_connection_complete: 841 case wlan_notification_acm_connection_complete:
842 case wlan_notification_acm_connection_attempt_fail: { 842 case wlan_notification_acm_connection_attempt_fail: {
843 PWLAN_CONNECTION_NOTIFICATION_DATA wlan_connection_data = 843 PWLAN_CONNECTION_NOTIFICATION_DATA wlan_connection_data =
844 reinterpret_cast<PWLAN_CONNECTION_NOTIFICATION_DATA>( 844 reinterpret_cast<PWLAN_CONNECTION_NOTIFICATION_DATA>(
845 wlan_notification_data->pData); 845 wlan_notification_data->pData);
846 message_loop_proxy_->PostTask( 846 event_task_runner_->PostTask(
847 FROM_HERE, 847 FROM_HERE, base::Bind(&WiFiServiceImpl::NotifyNetworkChanged,
848 base::Bind(&WiFiServiceImpl::NotifyNetworkChanged, 848 base::Unretained(this),
849 base::Unretained(this), 849 GUIDFromSSID(wlan_connection_data->dot11Ssid)));
850 GUIDFromSSID(wlan_connection_data->dot11Ssid)));
851 break; 850 break;
852 } 851 }
853 case wlan_notification_acm_scan_complete: 852 case wlan_notification_acm_scan_complete:
854 case wlan_notification_acm_interface_removal: 853 case wlan_notification_acm_interface_removal:
855 message_loop_proxy_->PostTask( 854 event_task_runner_->PostTask(
856 FROM_HERE, 855 FROM_HERE,
857 base::Bind(&WiFiServiceImpl::OnNetworkScanCompleteOnMainThread, 856 base::Bind(&WiFiServiceImpl::OnNetworkScanCompleteOnMainThread,
858 base::Unretained(this))); 857 base::Unretained(this)));
859 break; 858 break;
860 } 859 }
861 } 860 }
862 861
863 void WiFiServiceImpl::OnNetworkScanCompleteOnMainThread() { 862 void WiFiServiceImpl::OnNetworkScanCompleteOnMainThread() {
864 NetworkList networks; 863 NetworkList networks;
865 // Get current list of visible networks and notify that network list has 864 // Get current list of visible networks and notify that network list has
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 if (network_list_changed_observer_.is_null()) 1871 if (network_list_changed_observer_.is_null())
1873 return; 1872 return;
1874 1873
1875 NetworkGuidList current_networks; 1874 NetworkGuidList current_networks;
1876 for (NetworkList::const_iterator it = networks.begin(); 1875 for (NetworkList::const_iterator it = networks.begin();
1877 it != networks.end(); 1876 it != networks.end();
1878 ++it) { 1877 ++it) {
1879 current_networks.push_back(it->guid); 1878 current_networks.push_back(it->guid);
1880 } 1879 }
1881 1880
1882 message_loop_proxy_->PostTask( 1881 event_task_runner_->PostTask(
1883 FROM_HERE, 1882 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks));
1884 base::Bind(network_list_changed_observer_, current_networks));
1885 } 1883 }
1886 1884
1887 void WiFiServiceImpl::NotifyNetworkChanged(const std::string& network_guid) { 1885 void WiFiServiceImpl::NotifyNetworkChanged(const std::string& network_guid) {
1888 if (enable_notify_network_changed_ && !networks_changed_observer_.is_null()) { 1886 if (enable_notify_network_changed_ && !networks_changed_observer_.is_null()) {
1889 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; 1887 DVLOG(1) << "NotifyNetworkChanged: " << network_guid;
1890 NetworkGuidList changed_networks(1, network_guid); 1888 NetworkGuidList changed_networks(1, network_guid);
1891 message_loop_proxy_->PostTask( 1889 event_task_runner_->PostTask(
1892 FROM_HERE, 1890 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks));
1893 base::Bind(networks_changed_observer_, changed_networks));
1894 } 1891 }
1895 } 1892 }
1896 1893
1897 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } 1894 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); }
1898 1895
1899 } // namespace wifi 1896 } // namespace wifi
OLDNEW
« no previous file with comments | « components/wifi/wifi_service_mac.mm ('k') | components/wifi/wifi_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698