| OLD | NEW |
| 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 #ifndef CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_ |
| 6 #define CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 #include "chromeos/network/network_handler_callbacks.h" | 13 #include "chromeos/network/network_handler_callbacks.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 class NetworkState; |
| 18 |
| 17 // The NetworkActivationHandler class allows making service specific | 19 // The NetworkActivationHandler class allows making service specific |
| 18 // calls required for activation on mobile networks. | 20 // calls required for activation on mobile networks. |
| 19 class CHROMEOS_EXPORT NetworkActivationHandler | 21 class CHROMEOS_EXPORT NetworkActivationHandler |
| 20 : public base::SupportsWeakPtr<NetworkActivationHandler> { | 22 : public base::SupportsWeakPtr<NetworkActivationHandler> { |
| 21 public: | 23 public: |
| 22 // Constants for |error_name| from |error_callback|. | 24 // Constants for |error_name| from |error_callback|. |
| 23 // TODO(gauravsh): Merge various error constants from Network*Handlers into | 25 // TODO(gauravsh): Merge various error constants from Network*Handlers into |
| 24 // a single place. crbug.com/272554 | 26 // a single place. crbug.com/272554 |
| 25 static const char kErrorNotFound[]; | 27 static const char kErrorNotFound[]; |
| 26 static const char kErrorShillError[]; | 28 static const char kErrorShillError[]; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 // CompleteActivation() will start an asynchronous activation completion | 43 // CompleteActivation() will start an asynchronous activation completion |
| 42 // attempt. | 44 // attempt. |
| 43 // On success, |success_callback| will be called. | 45 // On success, |success_callback| will be called. |
| 44 // On failure, |error_callback| will be called with |error_name| one of: | 46 // On failure, |error_callback| will be called with |error_name| one of: |
| 45 // kErrorNotFound if no network matching |service_path| is found. | 47 // kErrorNotFound if no network matching |service_path| is found. |
| 46 // kErrorShillError if a DBus or Shill error occurred. | 48 // kErrorShillError if a DBus or Shill error occurred. |
| 47 void CompleteActivation(const std::string& service_path, | 49 void CompleteActivation(const std::string& service_path, |
| 48 const base::Closure& success_callback, | 50 const base::Closure& success_callback, |
| 49 const network_handler::ErrorCallback& error_callback); | 51 const network_handler::ErrorCallback& error_callback); |
| 50 | 52 |
| 53 // Returns true, if the network requires a service activation. |
| 54 static bool NetworkRequiresActivation(const NetworkState* network); |
| 55 |
| 51 private: | 56 private: |
| 52 friend class NetworkHandler; | 57 friend class NetworkHandler; |
| 53 | 58 |
| 54 NetworkActivationHandler(); | 59 NetworkActivationHandler(); |
| 55 | 60 |
| 56 // Calls Shill.Service.ActivateCellularModem asynchronously. | 61 // Calls Shill.Service.ActivateCellularModem asynchronously. |
| 57 void CallShillActivate(const std::string& service_path, | 62 void CallShillActivate(const std::string& service_path, |
| 58 const std::string& carrier, | 63 const std::string& carrier, |
| 59 const base::Closure& success_callback, | 64 const base::Closure& success_callback, |
| 60 const network_handler::ErrorCallback& error_callback); | 65 const network_handler::ErrorCallback& error_callback); |
| 61 | 66 |
| 62 // Calls Shill.Service.CompleteCellularActivation asynchronously. | 67 // Calls Shill.Service.CompleteCellularActivation asynchronously. |
| 63 void CallShillCompleteActivation( | 68 void CallShillCompleteActivation( |
| 64 const std::string& service_path, | 69 const std::string& service_path, |
| 65 const base::Closure& success_callback, | 70 const base::Closure& success_callback, |
| 66 const network_handler::ErrorCallback& error_callback); | 71 const network_handler::ErrorCallback& error_callback); |
| 67 | 72 |
| 68 // Handle success from Shill.Service.ActivateCellularModem or | 73 // Handle success from Shill.Service.ActivateCellularModem or |
| 69 // Shill.Service.CompleteCellularActivation. | 74 // Shill.Service.CompleteCellularActivation. |
| 70 void HandleShillSuccess(const std::string& service_path, | 75 void HandleShillSuccess(const std::string& service_path, |
| 71 const base::Closure& success_callback); | 76 const base::Closure& success_callback); |
| 72 | 77 |
| 73 DISALLOW_COPY_AND_ASSIGN(NetworkActivationHandler); | 78 DISALLOW_COPY_AND_ASSIGN(NetworkActivationHandler); |
| 74 }; | 79 }; |
| 75 | 80 |
| 76 } // namespace chromeos | 81 } // namespace chromeos |
| 77 | 82 |
| 78 #endif // CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_ | 83 #endif // CHROMEOS_NETWORK_NETWORK_ACTIVATION_HANDLER_H_ |
| OLD | NEW |