shill: wimax: Refactor service management out of WiMax into WiMaxProvider.
This allows WiMAX service management to be independent from the
availability of WiMAX devices.
BUG=chrome-os-partner:9907
TEST=unit tests
Change-Id: I52ad31ed8ef1d271b04bbd2cfc17729a5c112831
Reviewed-on: https://gerrit.chromium.org/gerrit/23511
Commit-Ready: Darin Petkov <petkov@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
diff --git a/wimax.h b/wimax.h
index 2d2226c..1000d7e 100644
--- a/wimax.h
+++ b/wimax.h
@@ -5,10 +5,11 @@
#ifndef SHILL_WIMAX_H_
#define SHILL_WIMAX_H_
+#include <set>
+
#include <gtest/gtest_prod.h> // for FRIEND_TEST
#include "shill/device.h"
-#include "shill/wimax_network_proxy_interface.h"
namespace shill {
@@ -33,36 +34,23 @@
virtual void Stop(Error *error, const EnabledStateChangedCallback &callback);
virtual bool TechnologyIs(const Technology::Identifier type) const;
virtual void Scan(Error *error);
- virtual bool Load(StoreInterface *storage);
virtual void ConnectTo(const WiMaxServiceRefPtr &service, Error *error);
- virtual void DisconnectFrom(const WiMaxServiceRefPtr &service, Error *error);
+ virtual void DisconnectFrom(const ServiceRefPtr &service, Error *error);
- // Finds or creates a service with the given parameters. The parameters
- // uniquely identify a service so no duplicate services will be created.
- WiMaxServiceRefPtr GetService(const WiMaxNetworkId &id,
- const std::string &name);
-
- // Starts all services with network ids in the current set of live
- // networks. This method also creates, registers and starts the default
- // service for each live network.
- virtual void StartLiveServices();
+ // Signaled by |service| when stopped.
+ virtual void OnServiceStopped(const WiMaxServiceRefPtr &service);
const RpcIdentifier &path() const { return path_; }
bool scanning() const { return scanning_; }
+ const std::set<RpcIdentifier> &networks() const { return networks_; }
private:
friend class WiMaxTest;
- FRIEND_TEST(WiMaxProviderTest, GetService);
- FRIEND_TEST(WiMaxTest, DestroyAllServices);
- FRIEND_TEST(WiMaxTest, FindService);
- FRIEND_TEST(WiMaxTest, GetDefaultService);
- FRIEND_TEST(WiMaxTest, GetService);
- FRIEND_TEST(WiMaxTest, LoadServices);
+ FRIEND_TEST(WiMaxProviderTest, OnNetworksChanged);
FRIEND_TEST(WiMaxTest, OnNetworksChanged);
- FRIEND_TEST(WiMaxTest, StartLiveServicesForNetwork);
+ FRIEND_TEST(WiMaxTest, OnServiceStopped);
FRIEND_TEST(WiMaxTest, StartStop);
- FRIEND_TEST(WiMaxTest, StopDeadServices);
static const int kTimeoutDefault;
@@ -76,36 +64,14 @@
void OnNetworksChanged(const RpcIdentifiers &networks);
- // Starts all services with a network id matching the network id of the
- // |network| RPC object. This method also creates, registers and starts the
- // default service for |network|.
- void StartLiveServicesForNetwork(const RpcIdentifier &network);
-
- // Stops all services with network ids that are not in the current set of live
- // networks.
- void StopDeadServices();
-
- // Deregisters all services from Manager and destroys them.
- void DestroyAllServices();
-
- // Finds to creates the default service for |network|.
- WiMaxServiceRefPtr GetDefaultService(const RpcIdentifier &network);
-
- // Finds and returns the service identified by |storage_id|. Returns NULL if
- // the service is not found.
- WiMaxServiceRefPtr FindService(const std::string &storage_id);
-
- // Creates and registers all WiMAX services available in |storage|. Returns
- // true if any services were created.
- bool LoadServices(StoreInterface *storage);
+ void DropConnection();
const RpcIdentifier path_;
scoped_ptr<WiMaxDeviceProxyInterface> proxy_;
bool scanning_;
- RpcIdentifiers networks_;
- std::vector<WiMaxServiceRefPtr> services_;
WiMaxServiceRefPtr pending_service_;
+ std::set<RpcIdentifier> networks_;
ProxyFactory *proxy_factory_;