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

Unified Diff: chromeos/network/network_connection_handler.cc

Issue 22674011: Handle connecting to hidden networks correctly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_connection_handler.cc
diff --git a/chromeos/network/network_connection_handler.cc b/chromeos/network/network_connection_handler.cc
index 25e03defdc509e9f05915969de7b70d1cc8b2c24..4f58d96f168e53c1b4d415dca39abe273bc7be08 100644
--- a/chromeos/network/network_connection_handler.cc
+++ b/chromeos/network/network_connection_handler.cc
@@ -233,24 +233,29 @@ void NetworkConnectionHandler::ConnectToNetwork(
// networks. These states will not be affected by a recent configuration.
const NetworkState* network =
pneubeck (no reviews) 2013/08/10 19:44:11 add a comment somewhere what it means if network==
stevenjb 2013/08/12 17:48:29 This should only happen if we call ConnectToNetwor
pneubeck (no reviews) 2013/08/12 18:35:01 Sounds reasonable. In particular c) is IMO very im
network_state_handler_->GetNetworkState(service_path);
- if (!network) {
- InvokeErrorCallback(service_path, error_callback, kErrorNotFound);
- return;
- }
- if (network->IsConnectedState()) {
- InvokeErrorCallback(service_path, error_callback, kErrorConnected);
- return;
- }
- if (network->IsConnectingState()) {
- InvokeErrorCallback(service_path, error_callback, kErrorConnecting);
- return;
- }
- if (NetworkRequiresActivation(network)) {
- InvokeErrorCallback(service_path, error_callback, kErrorActivationRequired);
- return;
+
+ if (network) {
+ // For existing networks, perform some immediate consistency checks.
+ if (network->IsConnectedState()) {
+ InvokeErrorCallback(service_path, error_callback, kErrorConnected);
+ return;
+ }
+ if (network->IsConnectingState()) {
+ InvokeErrorCallback(service_path, error_callback, kErrorConnecting);
+ return;
+ }
+ if (NetworkRequiresActivation(network)) {
+ InvokeErrorCallback(service_path, error_callback,
+ kErrorActivationRequired);
+ return;
+ }
}
if (check_error_state) {
+ if (!network) {
pneubeck (no reviews) 2013/08/10 19:44:11 this looks a bit contradicting to the handling if
stevenjb 2013/08/12 17:48:29 Yeah, this just ends up being confusing, and reall
+ InvokeErrorCallback(service_path, error_callback, kErrorNotFound);
+ return;
+ }
const std::string& error = network->error();
if (error == flimflam::kErrorConnectFailed) {
InvokeErrorCallback(
@@ -262,7 +267,6 @@ void NetworkConnectionHandler::ConnectToNetwork(
service_path, error_callback, kErrorPassphraseRequired);
return;
}
-
if (IsAuthenticationError(error)) {
InvokeErrorCallback(
service_path, error_callback, kErrorAuthenticationRequired);
@@ -275,27 +279,31 @@ void NetworkConnectionHandler::ConnectToNetwork(
service_path,
ConnectRequest(service_path, success_callback, error_callback)));
- // Connect immediately to 'connectable' networks.
- // TODO(stevenjb): Shill needs to properly set Connectable for VPN.
- if (network->connectable() && network->type() != flimflam::kTypeVPN) {
- CallShillConnect(service_path);
- return;
- }
+ if (network) {
+ // Connect immediately to 'connectable' networks.
+ // TODO(stevenjb): Shill needs to properly set Connectable for VPN.
+ if (network->connectable() && network->type() != flimflam::kTypeVPN) {
pneubeck (no reviews) 2013/08/10 19:44:11 For network==NULL, the connectable property will n
stevenjb 2013/08/12 17:48:29 Yes, I should add that there. Done.
+ CallShillConnect(service_path);
+ return;
+ }
- if (network->type() == flimflam::kTypeCellular ||
- (network->type() == flimflam::kTypeWifi &&
- network->security() == flimflam::kSecurityNone)) {
- NET_LOG_ERROR("Network has no security but is not 'Connectable'",
- service_path);
- CallShillConnect(service_path);
- return;
+ if (network->type() == flimflam::kTypeCellular ||
+ (network->type() == flimflam::kTypeWifi &&
+ network->security() == flimflam::kSecurityNone)) {
+ NET_LOG_ERROR("Network has no security but is not 'Connectable'",
+ service_path);
+ // Try to connect anyway. Failure may succeed anyway, or provide a
pneubeck (no reviews) 2013/08/10 19:44:11 "Failure may succeed" sounds wrong to me.
stevenjb 2013/08/12 17:48:29 Oops, bad edit. Looking at the code, I actually r
+ // helpful error from Shill.
+ CallShillConnect(service_path);
+ return;
+ }
}
// Request additional properties to check. VerifyConfiguredAndConnect will
// use only these properties, not cached properties, to ensure that they
// are up to date after any recent configuration.
network_configuration_handler_->GetProperties(
- network->path(),
+ service_path,
base::Bind(&NetworkConnectionHandler::VerifyConfiguredAndConnect,
AsWeakPtr(), check_error_state),
base::Bind(&NetworkConnectionHandler::HandleConfigurationFailure,
@@ -583,10 +591,9 @@ void NetworkConnectionHandler::CheckPendingRequest(
return; // Request has not started, ignore update
const NetworkState* network =
network_state_handler_->GetNetworkState(service_path);
- if (!network) {
- ErrorCallbackForPendingRequest(service_path, kErrorNotFound);
- return;
- }
+ if (!network)
+ return; // NetworkState may not be be updated yet.
+
if (network->IsConnectingState()) {
request->connect_state = ConnectRequest::CONNECT_CONNECTING;
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698