OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
Kyle Horimoto
2017/07/05 21:49:13
Please revert changes to WifiHotspotConnector. You
Ryan Hansberry
2017/07/07 02:33:16
Done.
| |
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_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chromeos/components/tether/active_host.h" | 14 #include "chromeos/components/tether/active_host.h" |
15 #include "chromeos/network/network_state_handler_observer.h" | 15 #include "chromeos/network/network_state_handler_observer.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 class NetworkConnect; | 19 class NetworkConnect; |
20 class NetworkState; | 20 class NetworkState; |
21 class NetworkStateHandler; | 21 class NetworkStateHandler; |
22 | 22 |
23 namespace tether { | 23 namespace tether { |
24 | 24 |
25 class HostConnectionMetricsLogger; | |
26 | |
25 // Connects to a Wi-Fi hotspot, given an SSID and password. | 27 // Connects to a Wi-Fi hotspot, given an SSID and password. |
26 class WifiHotspotConnector : public NetworkStateHandlerObserver { | 28 class WifiHotspotConnector : public NetworkStateHandlerObserver { |
27 public: | 29 public: |
28 WifiHotspotConnector(NetworkStateHandler* network_state_handler, | 30 WifiHotspotConnector( |
29 NetworkConnect* network_connect); | 31 NetworkStateHandler* network_state_handler, |
32 NetworkConnect* network_connect, | |
33 HostConnectionMetricsLogger* host_connection_metrics_logger); | |
30 ~WifiHotspotConnector() override; | 34 ~WifiHotspotConnector() override; |
31 | 35 |
32 // Function which receives the GUID of the connected Wi-Fi hotspot. If | 36 // Function which receives the GUID of the connected Wi-Fi hotspot. If |
33 // the string passed is empty, an error occurred trying to connect. | 37 // the string passed is empty, an error occurred trying to connect. |
34 using WifiConnectionCallback = base::Callback<void(const std::string&)>; | 38 using WifiConnectionCallback = base::Callback<void(const std::string&)>; |
35 | 39 |
36 // Connects to the Wi-Fi network with SSID |ssid| and password |password|, | 40 // Connects to the Wi-Fi network with SSID |ssid| and password |password|, |
37 // invoking |callback| when the connection succeeds, fails, or times out. | 41 // invoking |callback| when the connection succeeds, fails, or times out. |
38 // Note: If ConnectToWifiHotspot() is called while another connection attempt | 42 // Note: If ConnectToWifiHotspot() is called while another connection attempt |
39 // is in progress, the previous attempt will be canceled and the new attempt | 43 // is in progress, the previous attempt will be canceled and the new attempt |
(...skipping 16 matching lines...) Expand all Loading... | |
56 void InvokeWifiConnectionCallback(const std::string& wifi_guid); | 60 void InvokeWifiConnectionCallback(const std::string& wifi_guid); |
57 base::DictionaryValue CreateWifiPropertyDictionary( | 61 base::DictionaryValue CreateWifiPropertyDictionary( |
58 const std::string& ssid, | 62 const std::string& ssid, |
59 const std::string& password); | 63 const std::string& password); |
60 void OnConnectionTimeout(); | 64 void OnConnectionTimeout(); |
61 | 65 |
62 void SetTimerForTest(std::unique_ptr<base::Timer> timer); | 66 void SetTimerForTest(std::unique_ptr<base::Timer> timer); |
63 | 67 |
64 NetworkStateHandler* network_state_handler_; | 68 NetworkStateHandler* network_state_handler_; |
65 NetworkConnect* network_connect_; | 69 NetworkConnect* network_connect_; |
70 HostConnectionMetricsLogger* host_connection_metrics_logger_; | |
66 std::unique_ptr<base::Timer> timer_; | 71 std::unique_ptr<base::Timer> timer_; |
67 | 72 |
68 std::string ssid_; | 73 std::string ssid_; |
69 std::string password_; | 74 std::string password_; |
70 std::string tether_network_guid_; | 75 std::string tether_network_guid_; |
71 std::string wifi_network_guid_; | 76 std::string wifi_network_guid_; |
72 WifiConnectionCallback callback_; | 77 WifiConnectionCallback callback_; |
73 bool has_initiated_connection_to_current_network_ = false; | 78 bool has_initiated_connection_to_current_network_ = false; |
74 | 79 |
75 base::WeakPtrFactory<WifiHotspotConnector> weak_ptr_factory_; | 80 base::WeakPtrFactory<WifiHotspotConnector> weak_ptr_factory_; |
76 | 81 |
77 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnector); | 82 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnector); |
78 }; | 83 }; |
79 | 84 |
80 } // namespace tether | 85 } // namespace tether |
81 | 86 |
82 } // namespace chromeos | 87 } // namespace chromeos |
83 | 88 |
84 #endif // CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ | 89 #endif // CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ |
OLD | NEW |