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

Side by Side Diff: chromeos/network/network_activation_handler.cc

Issue 23532065: Add NetworkState::RequiresActivation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_activation_handler.h" 5 #include "chromeos/network/network_activation_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/shill_service_client.h" 10 #include "chromeos/dbus/shill_service_client.h"
11 #include "chromeos/network/network_event_log.h" 11 #include "chromeos/network/network_event_log.h"
12 #include "chromeos/network/network_handler.h" 12 #include "chromeos/network/network_handler.h"
13 #include "chromeos/network/network_state.h"
13 #include "dbus/object_proxy.h" 14 #include "dbus/object_proxy.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h"
14 16
15 namespace chromeos { 17 namespace chromeos {
16 18
17 // static 19 // static
18 const char NetworkActivationHandler::kErrorShillError[] = "shill-error"; 20 const char NetworkActivationHandler::kErrorShillError[] = "shill-error";
19 21
20 NetworkActivationHandler::NetworkActivationHandler() {} 22 NetworkActivationHandler::NetworkActivationHandler() {}
21 NetworkActivationHandler::~NetworkActivationHandler() {} 23 NetworkActivationHandler::~NetworkActivationHandler() {}
22 24
23 void NetworkActivationHandler::Activate( 25 void NetworkActivationHandler::Activate(
24 const std::string& service_path, 26 const std::string& service_path,
25 const std::string& carrier, 27 const std::string& carrier,
26 const base::Closure& success_callback, 28 const base::Closure& success_callback,
27 const network_handler::ErrorCallback& error_callback) { 29 const network_handler::ErrorCallback& error_callback) {
28 NET_LOG_USER("ActivateNetwork", service_path); 30 NET_LOG_USER("ActivateNetwork", service_path);
29 CallShillActivate(service_path, carrier, success_callback, error_callback); 31 CallShillActivate(service_path, carrier, success_callback, error_callback);
30 } 32 }
31 33
32 void NetworkActivationHandler::CompleteActivation( 34 void NetworkActivationHandler::CompleteActivation(
33 const std::string& service_path, 35 const std::string& service_path,
34 const base::Closure& success_callback, 36 const base::Closure& success_callback,
35 const network_handler::ErrorCallback& error_callback) { 37 const network_handler::ErrorCallback& error_callback) {
36 NET_LOG_USER("CompleteActivation", service_path); 38 NET_LOG_USER("CompleteActivation", service_path);
37 CallShillCompleteActivation(service_path, success_callback, error_callback); 39 CallShillCompleteActivation(service_path, success_callback, error_callback);
38 } 40 }
39 41
42 bool NetworkActivationHandler::NetworkRequiresActivation(
43 const NetworkState* network) {
44 return (network->type() == flimflam::kTypeCellular &&
45 network->activation_state() != flimflam::kActivationStateActivated &&
46 network->activation_state() != flimflam::kActivationStateUnknown);
stevenjb 2013/09/13 18:28:53 Since this takes a NetworkState* and only uses Net
armansito 2013/09/16 21:19:20 Done.
47 }
48
40 void NetworkActivationHandler::CallShillActivate( 49 void NetworkActivationHandler::CallShillActivate(
41 const std::string& service_path, 50 const std::string& service_path,
42 const std::string& carrier, 51 const std::string& carrier,
43 const base::Closure& success_callback, 52 const base::Closure& success_callback,
44 const network_handler::ErrorCallback& error_callback) { 53 const network_handler::ErrorCallback& error_callback) {
45 NET_LOG_USER("Activation Request", service_path + ": '" + carrier + "'"); 54 NET_LOG_USER("Activation Request", service_path + ": '" + carrier + "'");
46 DBusThreadManager::Get()->GetShillServiceClient()->ActivateCellularModem( 55 DBusThreadManager::Get()->GetShillServiceClient()->ActivateCellularModem(
47 dbus::ObjectPath(service_path), 56 dbus::ObjectPath(service_path),
48 carrier, 57 carrier,
49 base::Bind(&NetworkActivationHandler::HandleShillSuccess, 58 base::Bind(&NetworkActivationHandler::HandleShillSuccess,
(...skipping 16 matching lines...) Expand all
66 } 75 }
67 76
68 void NetworkActivationHandler::HandleShillSuccess( 77 void NetworkActivationHandler::HandleShillSuccess(
69 const std::string& service_path, 78 const std::string& service_path,
70 const base::Closure& success_callback) { 79 const base::Closure& success_callback) {
71 if (!success_callback.is_null()) 80 if (!success_callback.is_null())
72 success_callback.Run(); 81 success_callback.Run();
73 } 82 }
74 83
75 } // namespace chromeos 84 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_activation_handler.h ('k') | chromeos/network/network_connection_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698