OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_NETWORK_NETWORK_CONNECTION_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Additional configuration is required. | 67 // Additional configuration is required. |
68 static const char kErrorConfigurationRequired[]; | 68 static const char kErrorConfigurationRequired[]; |
69 | 69 |
70 // Configuration failed during the configure stage of the connect flow. | 70 // Configuration failed during the configure stage of the connect flow. |
71 static const char kErrorConfigureFailed[]; | 71 static const char kErrorConfigureFailed[]; |
72 | 72 |
73 // An unexpected DBus, Shill, or Tether communication error occurred while | 73 // An unexpected DBus, Shill, or Tether communication error occurred while |
74 // connecting. | 74 // connecting. |
75 static const char kErrorConnectFailed[]; | 75 static const char kErrorConnectFailed[]; |
76 | 76 |
77 // An unexpected DBus or Shill error occurred while disconnecting. | 77 // An unexpected DBus, Shill, or Tether error occurred while disconnecting. |
78 static const char kErrorDisconnectFailed[]; | 78 static const char kErrorDisconnectFailed[]; |
79 | 79 |
80 // A new network connect request canceled this one. | 80 // A new network connect request canceled this one. |
81 static const char kErrorConnectCanceled[]; | 81 static const char kErrorConnectCanceled[]; |
82 | 82 |
83 // Constants for |error_name| from |error_callback| for Disconnect. | 83 // Constants for |error_name| from |error_callback| for Disconnect. |
84 static const char kErrorNotConnected[]; | 84 static const char kErrorNotConnected[]; |
85 | 85 |
86 // Certificate load timed out. | 86 // Certificate load timed out. |
87 static const char kErrorCertLoadTimeout[]; | 87 static const char kErrorCertLoadTimeout[]; |
88 | 88 |
89 // Trying to configure an unmanged network but policy prohibits that | 89 // Trying to configure an unmanged network but policy prohibits that |
90 static const char kErrorUnmanagedNetwork[]; | 90 static const char kErrorUnmanagedNetwork[]; |
91 | 91 |
92 // Network activation failed. | 92 // Network activation failed. |
93 static const char kErrorActivateFailed[]; | 93 static const char kErrorActivateFailed[]; |
94 | 94 |
95 // Network was enabled/disabled when it was not available. | 95 // Network was enabled/disabled when it was not available. |
96 static const char kErrorEnabledOrDisabledWhenNotAvailable[]; | 96 static const char kErrorEnabledOrDisabledWhenNotAvailable[]; |
97 | 97 |
98 // Connection to Tether network attempted when no tether delegate present. | 98 // Connection or disconnection to Tether network attempted when no tether |
99 static const char kErrorTetherConnectionAttemptWithNoDelegate[]; | 99 // delegate present. |
| 100 static const char kErrorTetherAttemptWithNoDelegate[]; |
100 | 101 |
101 class CHROMEOS_EXPORT TetherDelegate { | 102 class CHROMEOS_EXPORT TetherDelegate { |
102 public: | 103 public: |
103 // Connects to the Tether network with GUID |tether_network_guid|. On | 104 // Connects to the Tether network with GUID |tether_network_guid|. On |
104 // success, invokes |success_callback|, and on failure, invokes | 105 // success, invokes |success_callback|, and on failure, invokes |
105 // |error_callback|, passing the relevant error code declared above. | 106 // |error_callback|, passing the relevant error code declared above. |
106 virtual void ConnectToNetwork( | 107 virtual void ConnectToNetwork( |
107 const std::string& tether_network_guid, | 108 const std::string& tether_network_guid, |
108 const base::Closure& success_callback, | 109 const base::Closure& success_callback, |
109 const network_handler::StringResultCallback& error_callback) = 0; | 110 const network_handler::StringResultCallback& error_callback) = 0; |
110 | 111 |
| 112 // Disconnects from the Tether network with GUID |tether_network_guid|. On |
| 113 // success, invokes |success_callback|, and on failure, invokes |
| 114 // |error_callback|, passing the relevant error code declared above. |
| 115 virtual void DisconnectFromNetwork( |
| 116 const std::string& tether_network_guid, |
| 117 const base::Closure& success_callback, |
| 118 const network_handler::StringResultCallback& error_callback) = 0; |
| 119 |
111 protected: | 120 protected: |
112 virtual ~TetherDelegate() {} | 121 virtual ~TetherDelegate() {} |
113 }; | 122 }; |
114 | 123 |
115 virtual ~NetworkConnectionHandler(); | 124 virtual ~NetworkConnectionHandler(); |
116 | 125 |
117 void AddObserver(NetworkConnectionObserver* observer); | 126 void AddObserver(NetworkConnectionObserver* observer); |
118 void RemoveObserver(NetworkConnectionObserver* observer); | 127 void RemoveObserver(NetworkConnectionObserver* observer); |
119 | 128 |
120 // Sets the TetherDelegate to handle Tether actions. |tether_delegate| is | 129 // Sets the TetherDelegate to handle Tether actions. |tether_delegate| is |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const std::string& service_path, | 181 const std::string& service_path, |
173 const network_handler::ErrorCallback& error_callback, | 182 const network_handler::ErrorCallback& error_callback, |
174 const std::string& error_name); | 183 const std::string& error_name); |
175 | 184 |
176 // Initiates a connection to a Tether network. | 185 // Initiates a connection to a Tether network. |
177 void InitiateTetherNetworkConnection( | 186 void InitiateTetherNetworkConnection( |
178 const std::string& tether_network_guid, | 187 const std::string& tether_network_guid, |
179 const base::Closure& success_callback, | 188 const base::Closure& success_callback, |
180 const network_handler::ErrorCallback& error_callback); | 189 const network_handler::ErrorCallback& error_callback); |
181 | 190 |
| 191 // Initiates a disconnection from a Tether network. |
| 192 void InitiateTetherNetworkDisconnection( |
| 193 const std::string& tether_network_guid, |
| 194 const base::Closure& success_callback, |
| 195 const network_handler::ErrorCallback& error_callback); |
| 196 |
182 base::ObserverList<NetworkConnectionObserver, true> observers_; | 197 base::ObserverList<NetworkConnectionObserver, true> observers_; |
183 | 198 |
184 // Delegate used to start a connection to a tether network. | 199 // Delegate used to start a connection to a tether network. |
185 TetherDelegate* tether_delegate_; | 200 TetherDelegate* tether_delegate_; |
186 | 201 |
187 private: | 202 private: |
188 // Only to be used by NetworkConnectionHandler implementation (and not by | 203 // Only to be used by NetworkConnectionHandler implementation (and not by |
189 // derived classes). | 204 // derived classes). |
190 base::WeakPtrFactory<NetworkConnectionHandler> weak_ptr_factory_; | 205 base::WeakPtrFactory<NetworkConnectionHandler> weak_ptr_factory_; |
191 | 206 |
192 DISALLOW_COPY_AND_ASSIGN(NetworkConnectionHandler); | 207 DISALLOW_COPY_AND_ASSIGN(NetworkConnectionHandler); |
193 }; | 208 }; |
194 | 209 |
195 } // namespace chromeos | 210 } // namespace chromeos |
196 | 211 |
197 #endif // CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ | 212 #endif // CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ |
OLD | NEW |