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

Unified Diff: chrome/browser/chromeos/mobile/mobile_activator.h

Issue 22611005: Switch over MobileActivator to use Network*Handler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ws Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/chromeos/network/network_connect.cc ('k') | chrome/browser/chromeos/mobile/mobile_activator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/mobile/mobile_activator.h
diff --git a/chrome/browser/chromeos/mobile/mobile_activator.h b/chrome/browser/chromeos/mobile/mobile_activator.h
index 3ba0e86e38ff3fc715887c1285b4a35367c46dcb..19bf15863cd93a1d90563b77999d4546f5fae4bc 100644
--- a/chrome/browser/chromeos/mobile/mobile_activator.h
+++ b/chrome/browser/chromeos/mobile/mobile_activator.h
@@ -9,14 +9,22 @@
#include <string>
#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
#include "base/memory/singleton.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
-#include "chrome/browser/chromeos/cros/network_library.h"
+#include "base/timer/timer.h"
+#include "chromeos/network/network_handler_callbacks.h"
+#include "chromeos/network/network_state_handler_observer.h"
#include "content/public/browser/browser_thread.h"
+namespace base {
+class DictionaryValue;
+}
+
namespace chromeos {
+class NetworkState;
class TestMobileActivator;
// Cellular plan config document.
@@ -48,9 +56,8 @@ class CellularConfigDocument
// This class performs mobile plan activation process.
class MobileActivator
- : public NetworkLibrary::NetworkManagerObserver,
- public NetworkLibrary::NetworkObserver,
- public base::SupportsWeakPtr<MobileActivator> {
+ : public base::SupportsWeakPtr<MobileActivator>,
+ public NetworkStateHandlerObserver {
public:
// Activation state.
enum PlanActivationState {
@@ -91,7 +98,7 @@ class MobileActivator
public:
// Signals activation |state| change for given |network|.
virtual void OnActivationStateChanged(
- CellularNetwork* network,
+ const NetworkState* network,
PlanActivationState state,
const std::string& error_description) = 0;
@@ -133,11 +140,9 @@ class MobileActivator
MobileActivator();
virtual ~MobileActivator();
- // NetworkLibrary::NetworkManagerObserver overrides.
- virtual void OnNetworkManagerChanged(NetworkLibrary* obj) OVERRIDE;
- // NetworkLibrary::NetworkObserver overrides.
- virtual void OnNetworkChanged(NetworkLibrary* obj,
- const Network* network) OVERRIDE;
+ // NetworkStateHandlerObserver overrides.
+ virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE;
+ virtual void NetworkPropertiesUpdated(const NetworkState* network) OVERRIDE;
// Continue activation after inital setup (config load).
void ContinueActivation();
@@ -161,32 +166,57 @@ class MobileActivator
// Called when an OTASP attempt times out.
void HandleOTASPTimeout();
// Forces disconnect / reconnect when we detect portal connectivity issues.
- void ForceReconnect(CellularNetwork* network, PlanActivationState next_state);
+ void ForceReconnect(const NetworkState* network,
+ PlanActivationState next_state);
// Called when ForceReconnect takes too long to reconnect.
void ReconnectTimedOut();
+
+ // Called on default network changes to update cellular network activation
+ // state.
+ void RefreshCellularNetworks();
+
+ // Helper to get network state corresponding to service path. Provided
+ // for easy mocking in unit tests.
+ virtual const NetworkState* GetNetworkState(const std::string& service_path);
+
// Verify the state of cellular network and modify internal state.
- virtual void EvaluateCellularNetwork(CellularNetwork* network);
+ virtual void EvaluateCellularNetwork(const NetworkState* network);
// PickNextState selects the desired state based on the current state of the
// modem and the activator. It does not transition to this state however.
- PlanActivationState PickNextState(CellularNetwork* network,
+ PlanActivationState PickNextState(const NetworkState* network,
std::string* error_description) const;
// One of PickNext*State are called in PickNextState based on whether the
// modem is online or not.
- PlanActivationState PickNextOnlineState(CellularNetwork* network) const;
- PlanActivationState PickNextOfflineState(CellularNetwork* network) const;
+ PlanActivationState PickNextOnlineState(const NetworkState* network) const;
+ PlanActivationState PickNextOfflineState(const NetworkState* network) const;
// Check the current cellular network for error conditions.
- bool GotActivationError(CellularNetwork* network,
+ bool GotActivationError(const NetworkState* network,
std::string* error) const;
// Sends status updates to WebUI page.
- void UpdatePage(CellularNetwork* network,
+ void UpdatePage(const NetworkState* network,
const std::string& error_description);
+
+ // Callback used to handle an activation error.
+ void HandleActivationFailure(
+ const std::string& service_path,
+ PlanActivationState new_state,
+ const std::string& error_name,
+ scoped_ptr<base::DictionaryValue> error_data);
+
+ // Request cellular activation for |network|.
+ // On success, |success_callback| will be called.
+ // On failure, |error_callback| will be called.
+ virtual void RequestCellularActivation(
+ const NetworkState* network,
+ const base::Closure& success_callback,
+ const network_handler::ErrorCallback& error_callback);
+
// Changes internal state.
- virtual void ChangeState(CellularNetwork* network,
+ virtual void ChangeState(const NetworkState* network,
PlanActivationState new_state,
const std::string& error_description);
// Resets network devices after cellular activation process.
- // |network| should be NULL if the activation process failed.
- void CompleteActivation(CellularNetwork* network);
+ void CompleteActivation();
// Disables SSL certificate revocation checking mechanism. In the case
// where captive portal connection is the only one present, such revocation
// checks could prevent payment portal page from loading.
@@ -196,9 +226,6 @@ class MobileActivator
// Return error message for a given code.
std::string GetErrorMessage(const std::string& code) const;
- // Converts the currently active CellularNetwork device into a JS object.
- static void GetDeviceInfo(CellularNetwork* network,
- DictionaryValue* value);
static bool ShouldReportDeviceState(std::string* state, std::string* error);
// Performs activation state cellular device evaluation.
@@ -207,16 +234,17 @@ class MobileActivator
static bool EvaluateCellularDeviceState(bool* report_status,
std::string* state,
std::string* error);
- // Finds cellular network that matches |meid_| or |iccid_|, reattach network
- // change observer if |reattach_observer| flag is set.
- virtual CellularNetwork* FindMatchingCellularNetwork(bool reattach_observer);
// Starts the OTASP timeout timer. If the timer fires, we'll force a
// disconnect/reconnect cycle on this network.
virtual void StartOTASPTimer();
- static const char* GetStateDescription(PlanActivationState state);
+ // Records information that cellular plan payment has happened.
+ virtual void SignalCellularPlanPayment();
- virtual NetworkLibrary* GetNetworkLibrary() const;
+ // Returns true if cellular plan payment has been recorded recently.
+ virtual bool HasRecentCellularPlanPayment() const;
+
+ static const char* GetStateDescription(PlanActivationState state);
scoped_refptr<CellularConfigDocument> cellular_config_;
// Internal handler state.
@@ -228,11 +256,18 @@ class MobileActivator
// Service path of network being activated. Note that the path can change
// during the activation process while still representing the same service.
std::string service_path_;
+ // Device on which the network service is activated. While the service path
+ // can change during activation due to modem resets, the device path stays
+ // the same.
+ std::string device_path_;
// Flags that controls if cert_checks needs to be restored
// after the activation of cellular network.
bool reenable_cert_check_;
// True if activation process has been terminated.
bool terminated_;
+ // True if an asynchronous activation request was dispatched to Shill
+ // but the succcess or failure of the request is yet unknown.
+ bool pending_activation_request_;
// Connection retry counter.
int connection_retry_count_;
// Counters for how many times we've tried each OTASP step.
@@ -250,7 +285,8 @@ class MobileActivator
base::RepeatingTimer<MobileActivator> continue_reconnect_timer_;
// Called when the reconnect attempt times out.
base::OneShotTimer<MobileActivator> reconnect_timeout_timer_;
-
+ // Cellular plan payment time.
+ base::Time cellular_plan_payment_time_;
ObserverList<Observer> observers_;
« no previous file with comments | « ash/system/chromeos/network/network_connect.cc ('k') | chrome/browser/chromeos/mobile/mobile_activator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698