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

Unified Diff: src/service_manager.h

Issue 6395007: cashew: gmock integration (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 9 years, 11 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 | « src/service_impl.cc ('k') | src/service_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/service_manager.h
diff --git a/src/service_manager.h b/src/service_manager.h
index d743f6cfd260e5fe15f160374e8cfa12759a16e2..97fdee6cde5cc0e8d4cd8e20678c0115e417e2f0 100644
--- a/src/service_manager.h
+++ b/src/service_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2010, 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,8 +14,6 @@
#include <base/basictypes.h> // NOLINT
#include <dbus-c++/dbus.h> // NOLINT
-#include "src/flimflam_manager_client_glue.h"
-#include "src/property_changed_handler.h"
#include "src/service.h"
namespace cashew {
@@ -28,29 +26,27 @@ typedef std::map<std::string, Service*> ServiceMap;
// vector of DBus::Path objects (strings) representing service path names
typedef std::vector<DBus::Path> ServicePathList;
+// ServiceManager interface
// monitors Flimflam and maintains a collection of cellular service objects
-class ServiceManager : public org::chromium::flimflam::Manager_proxy,
- public DBus::IntrospectableProxy,
- public DBus::ObjectProxy,
- public PropertyChangedDelegate {
+class ServiceManager {
public:
- ServiceManager(DBus::Connection& connection, // NOLINT
- GMainLoop * const main_loop);
- virtual ~ServiceManager();
+ ServiceManager() {}
+ virtual ~ServiceManager() {}
// look up a service by its path name
// returns NULL if service is not found
- virtual const Service* GetService(const std::string& service_path) const;
+ virtual const Service* GetService(const std::string& service_path) const
+ = 0;
// set Cashew server
// we'll talk to it when we want to emit updates to the world on behalf of
// our child Services.
// it's ok to clear this by setting it to NULL, in which case our updates
// will go into a black hole.
- virtual void SetCashewServer(CashewServer *cashew_server);
+ virtual void SetCashewServer(CashewServer *cashew_server) = 0;
// return our latest info on the current default technology
- virtual Service::Type GetDefaultTechnology() const;
+ virtual Service::Type GetDefaultTechnology() const = 0;
// valid Flimflam global connectivity state values
typedef enum {
@@ -61,7 +57,7 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
} ConnectivityState;
// return our latest info on Flimflam's global connectivity state
- virtual ConnectivityState GetConnectivityState() const;
+ virtual ConnectivityState GetConnectivityState() const = 0;
// does |state| represent an offline state
static bool IsOfflineConnectivityState(ConnectivityState state);
@@ -69,137 +65,17 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// does |state| represent an online state
static bool IsOnlineConnectivityState(ConnectivityState state);
- // Flimflam Manager D-Bus Proxy methods
-
- // receive incoming PropertyChanged D-Bus signal from Flimflam and
- // schedule deferred processing
- virtual void PropertyChanged(const std::string& property_name,
- const DBus::Variant& new_value);
-
- // receive incoming StateChanged D-Bus signal from Flimflam, convert to a
- // PropertyChanged signal, and schedule deferred processing
- virtual void StateChanged(const std::string& new_state_string);
-
- // PropertyChangedDelegate methods
-
- // Perform deferred processing for an incoming PropertyChanged D-Bus signal
- // from Flimflam
- virtual void OnPropertyChanged(const PropertyChangedHandler *handler,
- const std::string& property_name,
- const DBus::Variant& new_value);
-
// Service methods
// a child Service wants us to emit an update about its data plans
- virtual void EmitDataPlansUpdate(const Service& service);
-
- // glib integration interface
-
- // get idle/timer source id
- virtual guint GetGetPropertiesSourceId() const;
-
- // set idle/timer source id
- virtual void SetGetPropertiesSourceId(guint source_id);
+ virtual void EmitDataPlansUpdate(const Service& service) = 0;
- // are we in the process of retrying our GetProperties call?
- virtual bool RetryingGetProperties() const;
-
- // set the retrying flag
- virtual void OnRetryingGetProperties(bool retrying);
+ // factory
+ static ServiceManager* NewServiceManager(
+ DBus::Connection& connection, // NOLINT
+ GMainLoop * const main_loop);
private:
- // D-Bus connection owned by our creator
- // shared with Service objs that we create
- DBus::Connection& connection_;
-
- // glib main loop
- GMainLoop * const main_loop_;
-
- // collection of Service objs representing cellular services
- ServiceMap services_;
-
- // Cashew server implementing our front-end interface
- CashewServer *cashew_server_;
-
- // default technology most recently reported by Flimflam
- Service::Type default_technology_;
-
- // the cellular service, if any, that we think is the default service
- // can be NULL if we don't know the default service or a non-cellular
- // service is the default
- Service *default_cellular_service_;
-
- // global connectivity state most recently reported by Flimflam
- ConnectivityState connectivity_state_;
-
- // GetProperties timer glib source id
- // 0 means no source
- guint get_properties_source_id_;
-
- // are we in the process of retrying our GetProperties call?
- // this flag exists to distinguish between our initial g_idle_add call
- // and our subsequent timer calls
- bool retrying_get_properties_;
-
- // Handler for deferred processing of D-Bus PropertyChanged signals.
- //
- // We construct and enqueue PropertyChangedSignal objects as D-Bus signals
- // arrive, and the handler calls our OnPropertyChanged method (part of our
- // PropertyChangedDelegate interface) later from the glib main loop.
- //
- // This is done to avoid a libdbus-c++ deadlock that can occur when dbus
- // messages are sent from within a dbus callback.
- PropertyChangedHandler property_changed_handler_;
-
- // delete a collection of services
- void DeleteServices(ServiceMap *service_map);
-
- // glib integration: static wrapper for GetFlimflamProperties
- // takes object ptr as data and invokes object->GetFlimflamProperties()
- static gboolean StaticGetFlimflamPropertiesCallback(gpointer data);
-
- // get interesting properties from Flimflam such as Services and
- // DefaultTechnology
- // returns true on success and false on failure
- bool GetFlimflamProperties();
-
- // we've received updated State info from Flimflam
- void OnStateUpdate(const std::string& new_state_string);
-
- // we've received updated DefaultTechnology info from Flimflam
- void OnDefaultTechnologyUpdate(const std::string& default_technology);
-
- // we've received updated Services info from Flimflam
- void OnServicesUpdate(const ServicePathList& paths);
-
- // Flimflam has started advertising a new service
- void OnNewService(const DBus::Path& path);
-
- // we've received updated default service info from Flimflam
- // NULL |path| means that there is no default service
- void OnDefaultServiceUpdate(const DBus::Path *path);
-
- // if |default_cellular_service_| points to a service, tell it
- // that it is no longer the default service and clear our ptr
- void ClearDefaultCellularService();
-
- // tell |service| that it is now the default service and set our
- // |default_cellular_service_| ptr to point to it.
- // if there is already a default service, first clear it.
- // NULL |service| is ok and is equivalent to ClearDefaultCellularService
- // no-op if |service| == |default_cellular_service_|
- void SetDefaultCellularService(Service *service);
-
- // convert connectivity state string to ConnectivityState enum value
- static ConnectivityState ConnectivityStateFromString(
- const std::string& state);
-
- // Flimflam has told us that it has come online
- void OnFlimflamOnline();
-
- // Flimflam has told us that it has gone offline
- void OnFlimflamOffline();
-
DISALLOW_COPY_AND_ASSIGN(ServiceManager);
};
« no previous file with comments | « src/service_impl.cc ('k') | src/service_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698