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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); | 307 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); |
308 return; | 308 return; |
309 } | 309 } |
310 if (!network->IsConnectedState()) { | 310 if (!network->IsConnectedState()) { |
311 InvokeErrorCallback(service_path, error_callback, kErrorNotConnected); | 311 InvokeErrorCallback(service_path, error_callback, kErrorNotConnected); |
312 return; | 312 return; |
313 } | 313 } |
314 CallShillDisconnect(service_path, success_callback, error_callback); | 314 CallShillDisconnect(service_path, success_callback, error_callback); |
315 } | 315 } |
316 | 316 |
317 void NetworkConnectionHandler::ActivateNetwork( | |
318 const std::string& service_path, | |
319 const std::string& carrier, | |
320 const base::Closure& success_callback, | |
321 const network_handler::ErrorCallback& error_callback) { | |
322 NET_LOG_USER("DisconnectNetwork", service_path); | |
323 const NetworkState* network = | |
324 network_state_handler_->GetNetworkState(service_path); | |
325 if (!network) { | |
326 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); | |
327 return; | |
328 } | |
329 CallShillActivate(service_path, carrier, success_callback, error_callback); | |
330 } | |
331 | |
332 bool NetworkConnectionHandler::HasConnectingNetwork( | 317 bool NetworkConnectionHandler::HasConnectingNetwork( |
333 const std::string& service_path) { | 318 const std::string& service_path) { |
334 return pending_requests_.count(service_path) != 0; | 319 return pending_requests_.count(service_path) != 0; |
335 } | 320 } |
336 | 321 |
337 bool NetworkConnectionHandler::HasPendingConnectRequest() { | 322 bool NetworkConnectionHandler::HasPendingConnectRequest() { |
338 return pending_requests_.size() > 0; | 323 return pending_requests_.size() > 0; |
339 } | 324 } |
340 | 325 |
341 void NetworkConnectionHandler::NetworkListChanged() { | 326 void NetworkConnectionHandler::NetworkListChanged() { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 674 } |
690 | 675 |
691 void NetworkConnectionHandler::HandleShillDisconnectSuccess( | 676 void NetworkConnectionHandler::HandleShillDisconnectSuccess( |
692 const std::string& service_path, | 677 const std::string& service_path, |
693 const base::Closure& success_callback) { | 678 const base::Closure& success_callback) { |
694 NET_LOG_EVENT("Disconnect Request Sent", service_path); | 679 NET_LOG_EVENT("Disconnect Request Sent", service_path); |
695 if (!success_callback.is_null()) | 680 if (!success_callback.is_null()) |
696 success_callback.Run(); | 681 success_callback.Run(); |
697 } | 682 } |
698 | 683 |
699 // Activate | |
700 | |
701 void NetworkConnectionHandler::CallShillActivate( | |
702 const std::string& service_path, | |
703 const std::string& carrier, | |
704 const base::Closure& success_callback, | |
705 const network_handler::ErrorCallback& error_callback) { | |
706 NET_LOG_USER("Activate Request", service_path + ": '" + carrier + "'"); | |
707 DBusThreadManager::Get()->GetShillServiceClient()->ActivateCellularModem( | |
708 dbus::ObjectPath(service_path), | |
709 carrier, | |
710 base::Bind(&NetworkConnectionHandler::HandleShillActivateSuccess, | |
711 AsWeakPtr(), service_path, success_callback), | |
712 base::Bind(&network_handler::ShillErrorCallbackFunction, | |
713 kErrorShillError, service_path, error_callback)); | |
714 } | |
715 | |
716 void NetworkConnectionHandler::HandleShillActivateSuccess( | |
717 const std::string& service_path, | |
718 const base::Closure& success_callback) { | |
719 NET_LOG_EVENT("Activate Request Sent", service_path); | |
720 if (!success_callback.is_null()) | |
721 success_callback.Run(); | |
722 } | |
723 | |
724 } // namespace chromeos | 684 } // namespace chromeos |
OLD | NEW |