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

Side by Side Diff: chromeos/components/tether/wifi_hotspot_connector.h

Issue 2801353002: [CrOS Tether] Fill out the Initializer class. Tether will now initialize fully once the flag is ena… (Closed)
Patch Set: hansberry@ comments. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #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/network/network_state_handler_observer.h" 14 #include "chromeos/network/network_state_handler_observer.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 class NetworkConnect; 18 class NetworkConnect;
19 class NetworkState; 19 class NetworkState;
20 class NetworkStateHandler; 20 class NetworkStateHandler;
21 21
22 namespace tether { 22 namespace tether {
23 23
24 // Connects to a Wi-Fi hotspot, given an SSID and password. 24 // Connects to a Wi-Fi hotspot, given an SSID and password.
25 class WifiHotspotConnector : public NetworkStateHandlerObserver { 25 class WifiHotspotConnector : public NetworkStateHandlerObserver {
26 public: 26 public:
27 WifiHotspotConnector(NetworkStateHandler* network_state_handler, 27 WifiHotspotConnector();
28 NetworkConnect* network_connect);
29 ~WifiHotspotConnector() override; 28 ~WifiHotspotConnector() override;
30 29
31 // Function which receives the GUID of the connected Wi-Fi hotspot. If 30 // Function which receives the GUID of the connected Wi-Fi hotspot. If
32 // the string passed is empty, an error occurred trying to connect. 31 // the string passed is empty, an error occurred trying to connect.
33 using WifiConnectionCallback = base::Callback<void(const std::string&)>; 32 using WifiConnectionCallback = base::Callback<void(const std::string&)>;
34 33
35 // Connects to the Wi-Fi network with SSID |ssid| and password |password|, 34 // Connects to the Wi-Fi network with SSID |ssid| and password |password|,
36 // invoking |callback| when the connection succeeds, fails, or times out. 35 // invoking |callback| when the connection succeeds, fails, or times out.
37 // Note: If ConnectToWifiHotspot() is called while another connection attempt 36 // Note: If ConnectToWifiHotspot() is called while another connection attempt
38 // is in progress, the previous attempt will be canceled and the new attempt 37 // is in progress, the previous attempt will be canceled and the new attempt
39 // will begin. 38 // will begin.
40 virtual void ConnectToWifiHotspot(const std::string& ssid, 39 virtual void ConnectToWifiHotspot(const std::string& ssid,
41 const std::string& password, 40 const std::string& password,
42 const WifiConnectionCallback& callback); 41 const WifiConnectionCallback& callback);
43 42
44 // NetworkStateHandlerObserver: 43 // NetworkStateHandlerObserver:
45 void NetworkPropertiesUpdated(const NetworkState* network) override; 44 void NetworkPropertiesUpdated(const NetworkState* network) override;
46 45
46 protected:
47 WifiHotspotConnector(NetworkStateHandler* network_state_handler,
48 NetworkConnect* network_connect);
stevenjb 2017/04/10 20:26:59 One constructor
Kyle Horimoto 2017/04/11 01:40:40 Done.
49
47 private: 50 private:
48 friend class WifiHotspotConnectorTest; 51 friend class WifiHotspotConnectorTest;
49 52
50 static const int64_t kConnectionTimeoutSeconds = 20; 53 static const int64_t kConnectionTimeoutSeconds = 20;
51 54
52 // Passes an empty string as |wifi_guid| to signal that the connection did not 55 // Passes an empty string as |wifi_guid| to signal that the connection did not
53 // succeed. 56 // succeed.
54 void InvokeWifiConnectionCallback(const std::string& wifi_guid); 57 void InvokeWifiConnectionCallback(const std::string& wifi_guid);
55 base::DictionaryValue CreateWifiPropertyDictionary( 58 base::DictionaryValue CreateWifiPropertyDictionary(
56 const std::string& ssid, 59 const std::string& ssid,
(...skipping 14 matching lines...) Expand all
71 base::WeakPtrFactory<WifiHotspotConnector> weak_ptr_factory_; 74 base::WeakPtrFactory<WifiHotspotConnector> weak_ptr_factory_;
72 75
73 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnector); 76 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnector);
74 }; 77 };
75 78
76 } // namespace tether 79 } // namespace tether
77 80
78 } // namespace chromeos 81 } // namespace chromeos
79 82
80 #endif // CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_ 83 #endif // CHROMEOS_COMPONENTS_TETHER_WIFI_HOTSPOT_CONNECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698