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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_
6 #define CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_
10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/network/network_handler_callbacks.h"
17 // The NetworkActivationHandler class allows making service specific
18 // calls required for activation on mobile networks.
19 class CHROMEOS_EXPORT NetworkActivationHandler
20 : public base::SupportsWeakPtr
<NetworkActivationHandler
> {
22 // Constants for |error_name| from |error_callback|.
23 // TODO(gauravsh): Merge various error constants from Network*Handlers into
24 // a single place. crbug.com/272554
25 static const char kErrorNotFound
[];
26 static const char kErrorShillError
[];
28 virtual ~NetworkActivationHandler();
30 // ActivateNetwork() will start an asynchronous activation attempt.
31 // |carrier| may be empty or may specify a carrier to activate.
32 // On success, |success_callback| will be called.
33 // On failure, |error_callback| will be called with |error_name| one of:
34 // kErrorNotFound if no network matching |service_path| is found.
35 // kErrorShillError if a DBus or Shill error occurred.
36 void Activate(const std::string
& service_path
,
37 const std::string
& carrier
,
38 const base::Closure
& success_callback
,
39 const network_handler::ErrorCallback
& error_callback
);
41 // CompleteActivation() will start an asynchronous activation completion
43 // On success, |success_callback| will be called.
44 // On failure, |error_callback| will be called with |error_name| one of:
45 // kErrorNotFound if no network matching |service_path| is found.
46 // kErrorShillError if a DBus or Shill error occurred.
47 void CompleteActivation(const std::string
& service_path
,
48 const base::Closure
& success_callback
,
49 const network_handler::ErrorCallback
& error_callback
);
52 friend class NetworkHandler
;
54 NetworkActivationHandler();
56 // Calls Shill.Service.ActivateCellularModem asynchronously.
57 void CallShillActivate(const std::string
& service_path
,
58 const std::string
& carrier
,
59 const base::Closure
& success_callback
,
60 const network_handler::ErrorCallback
& error_callback
);
62 // Calls Shill.Service.CompleteCellularActivation asynchronously.
63 void CallShillCompleteActivation(
64 const std::string
& service_path
,
65 const base::Closure
& success_callback
,
66 const network_handler::ErrorCallback
& error_callback
);
68 // Handle success from Shill.Service.ActivateCellularModem or
69 // Shill.Service.CompleteCellularActivation.
70 void HandleShillSuccess(const std::string
& service_path
,
71 const base::Closure
& success_callback
);
73 DISALLOW_COPY_AND_ASSIGN(NetworkActivationHandler
);
76 } // namespace chromeos
78 #endif // CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_