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

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

Issue 2819303002: Changed wifi arcs to mobile bars for Tether network. (Closed)
Patch Set: Fixed small typo preventing unit tests from building. Created 3 years, 7 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/components/tether/active_host.h"
14 #include "chromeos/network/network_state_handler_observer.h" 15 #include "chromeos/network/network_state_handler_observer.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 class NetworkConnect; 19 class NetworkConnect;
19 class NetworkState; 20 class NetworkState;
20 class NetworkStateHandler; 21 class NetworkStateHandler;
21 22
22 namespace tether { 23 namespace tether {
23 24
24 // Connects to a Wi-Fi hotspot, given an SSID and password. 25 // Connects to a Wi-Fi hotspot, given an SSID and password.
25 class WifiHotspotConnector : public NetworkStateHandlerObserver { 26 class WifiHotspotConnector : public NetworkStateHandlerObserver {
26 public: 27 public:
27 WifiHotspotConnector(NetworkStateHandler* network_state_handler, 28 WifiHotspotConnector(NetworkStateHandler* network_state_handler,
28 NetworkConnect* network_connect); 29 NetworkConnect* network_connect);
29 ~WifiHotspotConnector() override; 30 ~WifiHotspotConnector() override;
30 31
31 // Function which receives the GUID of the connected Wi-Fi hotspot. If 32 // Function which receives the GUID of the connected Wi-Fi hotspot. If
32 // the string passed is empty, an error occurred trying to connect. 33 // the string passed is empty, an error occurred trying to connect.
33 using WifiConnectionCallback = base::Callback<void(const std::string&)>; 34 using WifiConnectionCallback = base::Callback<void(const std::string&)>;
34 35
35 // Connects to the Wi-Fi network with SSID |ssid| and password |password|, 36 // Connects to the Wi-Fi network with SSID |ssid| and password |password|,
36 // invoking |callback| when the connection succeeds, fails, or times out. 37 // invoking |callback| when the connection succeeds, fails, or times out.
37 // Note: If ConnectToWifiHotspot() is called while another connection attempt 38 // Note: If ConnectToWifiHotspot() is called while another connection attempt
38 // is in progress, the previous attempt will be canceled and the new attempt 39 // is in progress, the previous attempt will be canceled and the new attempt
39 // will begin. 40 // will begin.
40 virtual void ConnectToWifiHotspot(const std::string& ssid, 41 virtual void ConnectToWifiHotspot(const std::string& ssid,
41 const std::string& password, 42 const std::string& password,
43 const std::string& tether_network_guid,
42 const WifiConnectionCallback& callback); 44 const WifiConnectionCallback& callback);
43 45
44 // NetworkStateHandlerObserver: 46 // NetworkStateHandlerObserver:
45 void NetworkPropertiesUpdated(const NetworkState* network) override; 47 void NetworkPropertiesUpdated(const NetworkState* network) override;
46 48
47 private: 49 private:
48 friend class WifiHotspotConnectorTest; 50 friend class WifiHotspotConnectorTest;
49 51
50 static const int64_t kConnectionTimeoutSeconds = 20; 52 static const int64_t kConnectionTimeoutSeconds = 20;
51 53
52 // Passes an empty string as |wifi_guid| to signal that the connection did not 54 // Passes an empty string as |wifi_guid| to signal that the connection did not
53 // succeed. 55 // succeed.
54 void InvokeWifiConnectionCallback(const std::string& wifi_guid); 56 void InvokeWifiConnectionCallback(const std::string& wifi_guid);
55 base::DictionaryValue CreateWifiPropertyDictionary( 57 base::DictionaryValue CreateWifiPropertyDictionary(
56 const std::string& ssid, 58 const std::string& ssid,
57 const std::string& password); 59 const std::string& password);
58 void OnConnectionTimeout(); 60 void OnConnectionTimeout();
59 61
60 void SetTimerForTest(std::unique_ptr<base::Timer> timer); 62 void SetTimerForTest(std::unique_ptr<base::Timer> timer);
61 63
62 NetworkStateHandler* network_state_handler_; 64 NetworkStateHandler* network_state_handler_;
63 NetworkConnect* network_connect_; 65 NetworkConnect* network_connect_;
64 std::unique_ptr<base::Timer> timer_; 66 std::unique_ptr<base::Timer> timer_;
65 67
66 std::string ssid_; 68 std::string ssid_;
67 std::string password_; 69 std::string password_;
68 std::string wifi_guid_; 70 std::string tether_network_guid_;
71 std::string wifi_network_guid_;
69 WifiConnectionCallback callback_; 72 WifiConnectionCallback callback_;
70 73
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