OLD | NEW |
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_TETHER_CONNECTOR_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chromeos/components/tether/connect_tethering_operation.h" | 10 #include "chromeos/components/tether/connect_tethering_operation.h" |
| 11 #include "chromeos/components/tether/host_connection_metrics_logger.h" |
11 #include "chromeos/network/network_connection_handler.h" | 12 #include "chromeos/network/network_connection_handler.h" |
12 | 13 |
13 namespace chromeos { | 14 namespace chromeos { |
14 | 15 |
15 class NetworkStateHandler; | 16 class NetworkStateHandler; |
16 | 17 |
17 namespace tether { | 18 namespace tether { |
18 | 19 |
19 class ActiveHost; | 20 class ActiveHost; |
20 class BleConnectionManager; | 21 class BleConnectionManager; |
(...skipping 13 matching lines...) Expand all Loading... |
34 public: | 35 public: |
35 TetherConnector( | 36 TetherConnector( |
36 NetworkStateHandler* network_state_handler, | 37 NetworkStateHandler* network_state_handler, |
37 WifiHotspotConnector* wifi_hotspot_connector, | 38 WifiHotspotConnector* wifi_hotspot_connector, |
38 ActiveHost* active_host, | 39 ActiveHost* active_host, |
39 TetherHostFetcher* tether_host_fetcher, | 40 TetherHostFetcher* tether_host_fetcher, |
40 BleConnectionManager* connection_manager, | 41 BleConnectionManager* connection_manager, |
41 TetherHostResponseRecorder* tether_host_response_recorder, | 42 TetherHostResponseRecorder* tether_host_response_recorder, |
42 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map, | 43 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map, |
43 HostScanCache* host_scan_cache, | 44 HostScanCache* host_scan_cache, |
44 NotificationPresenter* notification_presenter); | 45 NotificationPresenter* notification_presenter, |
| 46 HostConnectionMetricsLogger* host_connection_metrics_logger); |
45 virtual ~TetherConnector(); | 47 virtual ~TetherConnector(); |
46 | 48 |
47 virtual void ConnectToNetwork( | 49 virtual void ConnectToNetwork( |
48 const std::string& tether_network_guid, | 50 const std::string& tether_network_guid, |
49 const base::Closure& success_callback, | 51 const base::Closure& success_callback, |
50 const network_handler::StringResultCallback& error_callback); | 52 const network_handler::StringResultCallback& error_callback); |
51 | 53 |
52 // Returns whether the connection attempt was successfully canceled. | 54 // Returns whether the connection attempt was successfully canceled. |
53 virtual bool CancelConnectionAttempt(const std::string& tether_network_guid); | 55 virtual bool CancelConnectionAttempt(const std::string& tether_network_guid); |
54 | 56 |
55 // ConnectTetheringOperation::Observer: | 57 // ConnectTetheringOperation::Observer: |
56 void OnSuccessfulConnectTetheringResponse( | 58 void OnSuccessfulConnectTetheringResponse( |
57 const cryptauth::RemoteDevice& remote_device, | 59 const cryptauth::RemoteDevice& remote_device, |
58 const std::string& ssid, | 60 const std::string& ssid, |
59 const std::string& password) override; | 61 const std::string& password) override; |
60 void OnConnectTetheringFailure( | 62 void OnConnectTetheringFailure( |
61 const cryptauth::RemoteDevice& remote_device, | 63 const cryptauth::RemoteDevice& remote_device, |
62 ConnectTetheringResponse_ResponseCode error_code) override; | 64 ConnectTetheringResponse_ResponseCode error_code) override; |
63 | 65 |
64 private: | 66 private: |
65 friend class TetherConnectorTest; | 67 friend class TetherConnectorTest; |
66 | 68 |
67 void SetConnectionFailed(const std::string& error_name); | 69 void SetConnectionFailed(const std::string& error_name, |
| 70 HostConnectionMetricsLogger::ConnectionToHostResult |
| 71 connection_to_host_result); |
68 void SetConnectionSucceeded(const std::string& device_id, | 72 void SetConnectionSucceeded(const std::string& device_id, |
69 const std::string& wifi_network_guid); | 73 const std::string& wifi_network_guid); |
70 | 74 |
71 void OnTetherHostToConnectFetched( | 75 void OnTetherHostToConnectFetched( |
72 const std::string& device_id, | 76 const std::string& device_id, |
73 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect); | 77 std::unique_ptr<cryptauth::RemoteDevice> tether_host_to_connect); |
74 void OnWifiConnection(const std::string& device_id, | 78 void OnWifiConnection(const std::string& device_id, |
75 const std::string& wifi_network_guid); | 79 const std::string& wifi_network_guid); |
| 80 HostConnectionMetricsLogger::ConnectionToHostResult |
| 81 GetConnectionToHostResultFromErrorCode( |
| 82 const std::string& device_id, |
| 83 ConnectTetheringResponse_ResponseCode error_code); |
76 | 84 |
77 NetworkConnectionHandler* network_connection_handler_; | 85 NetworkConnectionHandler* network_connection_handler_; |
78 NetworkStateHandler* network_state_handler_; | 86 NetworkStateHandler* network_state_handler_; |
79 WifiHotspotConnector* wifi_hotspot_connector_; | 87 WifiHotspotConnector* wifi_hotspot_connector_; |
80 ActiveHost* active_host_; | 88 ActiveHost* active_host_; |
81 TetherHostFetcher* tether_host_fetcher_; | 89 TetherHostFetcher* tether_host_fetcher_; |
82 BleConnectionManager* connection_manager_; | 90 BleConnectionManager* connection_manager_; |
83 TetherHostResponseRecorder* tether_host_response_recorder_; | 91 TetherHostResponseRecorder* tether_host_response_recorder_; |
84 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; | 92 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; |
85 HostScanCache* host_scan_cache_; | 93 HostScanCache* host_scan_cache_; |
86 NotificationPresenter* notification_presenter_; | 94 NotificationPresenter* notification_presenter_; |
| 95 HostConnectionMetricsLogger* host_connection_metrics_logger_; |
87 | 96 |
88 std::string device_id_pending_connection_; | 97 std::string device_id_pending_connection_; |
89 base::Closure success_callback_; | 98 base::Closure success_callback_; |
90 network_handler::StringResultCallback error_callback_; | 99 network_handler::StringResultCallback error_callback_; |
91 std::unique_ptr<ConnectTetheringOperation> connect_tethering_operation_; | 100 std::unique_ptr<ConnectTetheringOperation> connect_tethering_operation_; |
92 base::WeakPtrFactory<TetherConnector> weak_ptr_factory_; | 101 base::WeakPtrFactory<TetherConnector> weak_ptr_factory_; |
93 | 102 |
94 DISALLOW_COPY_AND_ASSIGN(TetherConnector); | 103 DISALLOW_COPY_AND_ASSIGN(TetherConnector); |
95 }; | 104 }; |
96 | 105 |
97 } // namespace tether | 106 } // namespace tether |
98 | 107 |
99 } // namespace chromeos | 108 } // namespace chromeos |
100 | 109 |
101 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ | 110 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_CONNECTOR_H_ |
OLD | NEW |