OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chromeos/network/network_connection_handler.h" | 5 #include "chromeos/network/network_connection_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 if (!network) { | 312 if (!network) { |
313 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); | 313 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); |
314 return; | 314 return; |
315 } | 315 } |
316 if (!network->IsConnectedState()) { | 316 if (!network->IsConnectedState()) { |
317 InvokeErrorCallback(service_path, error_callback, kErrorNotConnected); | 317 InvokeErrorCallback(service_path, error_callback, kErrorNotConnected); |
318 return; | 318 return; |
319 } | 319 } |
320 CallShillDisconnect(service_path, success_callback, error_callback); | 320 CallShillDisconnect(service_path, success_callback, error_callback); |
321 } | 321 } |
322 | 322 |
armansito
2013/08/14 00:49:51
A small suggestion: now that there is a NetworkAct
gauravsh
2013/08/14 21:42:29
NetworkRequiresActivation() is used by ConnectToNe
armansito
2013/08/14 22:46:34
sgtm.
| |
323 void NetworkConnectionHandler::ActivateNetwork( | |
324 const std::string& service_path, | |
325 const std::string& carrier, | |
326 const base::Closure& success_callback, | |
327 const network_handler::ErrorCallback& error_callback) { | |
328 NET_LOG_USER("DisconnectNetwork", service_path); | |
329 const NetworkState* network = | |
330 network_state_handler_->GetNetworkState(service_path); | |
331 if (!network) { | |
332 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); | |
333 return; | |
334 } | |
335 CallShillActivate(service_path, carrier, success_callback, error_callback); | |
336 } | |
337 | |
338 bool NetworkConnectionHandler::HasConnectingNetwork( | 323 bool NetworkConnectionHandler::HasConnectingNetwork( |
339 const std::string& service_path) { | 324 const std::string& service_path) { |
340 return pending_requests_.count(service_path) != 0; | 325 return pending_requests_.count(service_path) != 0; |
341 } | 326 } |
342 | 327 |
343 void NetworkConnectionHandler::NetworkListChanged() { | 328 void NetworkConnectionHandler::NetworkListChanged() { |
344 CheckAllPendingRequests(); | 329 CheckAllPendingRequests(); |
345 } | 330 } |
346 | 331 |
347 void NetworkConnectionHandler::NetworkPropertiesUpdated( | 332 void NetworkConnectionHandler::NetworkPropertiesUpdated( |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 } | 645 } |
661 | 646 |
662 void NetworkConnectionHandler::HandleShillDisconnectSuccess( | 647 void NetworkConnectionHandler::HandleShillDisconnectSuccess( |
663 const std::string& service_path, | 648 const std::string& service_path, |
664 const base::Closure& success_callback) { | 649 const base::Closure& success_callback) { |
665 NET_LOG_EVENT("Disconnect Request Sent", service_path); | 650 NET_LOG_EVENT("Disconnect Request Sent", service_path); |
666 if (!success_callback.is_null()) | 651 if (!success_callback.is_null()) |
667 success_callback.Run(); | 652 success_callback.Run(); |
668 } | 653 } |
669 | 654 |
670 // Activate | |
671 | |
672 void NetworkConnectionHandler::CallShillActivate( | |
673 const std::string& service_path, | |
674 const std::string& carrier, | |
675 const base::Closure& success_callback, | |
676 const network_handler::ErrorCallback& error_callback) { | |
677 NET_LOG_USER("Activate Request", service_path + ": '" + carrier + "'"); | |
678 DBusThreadManager::Get()->GetShillServiceClient()->ActivateCellularModem( | |
679 dbus::ObjectPath(service_path), | |
680 carrier, | |
681 base::Bind(&NetworkConnectionHandler::HandleShillActivateSuccess, | |
682 AsWeakPtr(), service_path, success_callback), | |
683 base::Bind(&network_handler::ShillErrorCallbackFunction, | |
684 kErrorShillError, service_path, error_callback)); | |
685 } | |
686 | |
687 void NetworkConnectionHandler::HandleShillActivateSuccess( | |
688 const std::string& service_path, | |
689 const base::Closure& success_callback) { | |
690 NET_LOG_EVENT("Activate Request Sent", service_path); | |
691 if (!success_callback.is_null()) | |
692 success_callback.Run(); | |
693 } | |
694 | |
695 } // namespace chromeos | 655 } // namespace chromeos |
OLD | NEW |