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

Unified Diff: src/device.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/cashew_unittest.cc ('k') | src/device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/device.h
diff --git a/src/device.h b/src/device.h
index dae74f6c7e9f785f6424d1189dbcfea8817684fc..79552344a6f17159f89cff84b799291139cc52aa 100644
--- a/src/device.h
+++ b/src/device.h
@@ -1,39 +1,29 @@
-// 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.
#ifndef SRC_DEVICE_H_
#define SRC_DEVICE_H_
-#include <glib.h>
-
#include <string>
#include <base/basictypes.h> // NOLINT
#include <dbus-c++/dbus.h> // NOLINT
-#include "src/byte_counter.h"
-#include "src/flimflam_device_client_glue.h"
-#include "src/property_changed_handler.h"
-
namespace cashew {
class ByteCounter;
class Service;
+// Device interface
// represents a cellular device and monitors Flimflam state for that device
-class Device : public org::chromium::flimflam::Device_proxy,
- public DBus::IntrospectableProxy,
- public DBus::ObjectProxy,
- public ByteCounterDelegate,
- public PropertyChangedDelegate {
+class Device {
public:
- Device(Service * const parent, DBus::Connection& connection, // NOLINT
- const DBus::Path& path);
- virtual ~Device();
+ Device() {}
+ virtual ~Device() {}
// get D-Bus path for this device
- virtual const DBus::Path& GetPath() const;
+ virtual const DBus::Path& GetPath() const = 0;
// valid type values for this device
typedef enum {
@@ -49,28 +39,15 @@ class Device : public org::chromium::flimflam::Device_proxy,
// get type for this device
// NOTE: for now, should always be kTypeCellular
- virtual Type GetType() const;
+ virtual Type GetType() const = 0;
// get cellular carrier for this device
// returns empty string if we don't know
- virtual const std::string& GetCarrier() const;
+ virtual const std::string& GetCarrier() const = 0;
// get interface name for this device (e.g., "usb0")
// returns empty string if we don't know
- virtual const std::string& GetInterface() const;
-
- // Flimflam Device D-Bus Proxy methods
-
- // receive incoming PropertyChanged D-Bus signal from Flimflam device and
- // schedule deferred processing
- virtual void PropertyChanged(const std::string& property_name,
- const DBus::Variant& new_value);
-
- // PropertyChangedDelegate methods
-
- virtual void OnPropertyChanged(const PropertyChangedHandler *handler,
- const std::string& property_name,
- const DBus::Variant& new_value);
+ virtual const std::string& GetInterface() const = 0;
// Service methods
@@ -78,101 +55,21 @@ class Device : public org::chromium::flimflam::Device_proxy,
// there must not be an existing byte counter
// |parent_| will receive periodic updates via Service::OnByteCounterUpdate
// returns true on success and false on failure
- virtual bool StartByteCounter();
+ virtual bool StartByteCounter() = 0;
// destroy any existing byte counter
// |parent_| will no longer receive updates after this call
- virtual void StopByteCounter();
+ virtual void StopByteCounter() = 0;
// is the byte counter running?
- virtual bool ByteCounterRunning() const;
-
- // glib integration interface
-
- // get idle/timer source id
- virtual guint GetGetPropertiesSourceId() const;
+ virtual bool ByteCounterRunning() const = 0;
- // set idle/timer source id
- virtual void SetGetPropertiesSourceId(guint source_id);
-
- // are we in the process of retrying our GetProperties call?
- virtual bool RetryingGetProperties() const;
-
- // set the retrying flag
- virtual void OnRetryingGetProperties(bool retrying);
-
- // ByteCounterDelegate methods
-
- // called when bye counter is updated
- virtual void OnByteCounterUpdate(const ByteCounter *counter,
- uint64 rx_bytes, uint64 tx_bytes);
+ // factory
+ static Device* NewDevice(Service * const parent,
+ DBus::Connection& connection, // NOLINT
+ const DBus::Path& path);
private:
- // back pointer to our parent Service
- Service * const parent_;
-
- // D-Bus path for Flimflam device that we represent
- // this is our unique identifier
- const DBus::Path path_;
-
- // device type
- Type type_;
-
- // cellular carrier
- std::string carrier_;
-
- // interface name
- std::string interface_;
-
- // 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_;
-
- // byte counter for this device
- // can be NULL
- ByteCounter *byte_counter_;
-
- // is the byte counter running?
- // this is distinct from whether or not byte_counter_ == NULL, since the
- // counter may be logically running but we may not yet know our interface
- // name and therefore may not yet have created a byte counter object.
- bool byte_counter_running_;
-
- // Handler for deferred processing of D-Bus PropertyChanged signals.
- // See comments in service_manager.h
- PropertyChangedHandler property_changed_handler_;
-
- // convert type string to Type enum value
- Type TypeFromString(const std::string& type) const;
-
- // we've received updated Cellular.Carrier info from Flimflam
- void OnCarrierUpdate(const std::string& carrier);
-
- // we've received updated Interface info from Flimflam
- void OnInterfaceUpdate(const std::string& interface);
-
- // we've received updated Type info from Flimflam
- void OnTypeUpdate(const std::string& type);
-
- // glib integration: static wrapper for GetDeviceProperties
- // takes object ptr as data and invokes object->GetDeviceProperties
- static gboolean StaticGetDevicePropertiesCallback(gpointer data);
-
- // get device properties from Flimflam
- // returns true on success and false on failure
- bool GetDeviceProperties();
-
- // create a byte counter object and assign it to |byte_counter_|
- bool CreateByteCounter();
-
- // delete byte counter object pointed to by |byte_counter_| if any
- void DeleteByteCounter();
-
DISALLOW_COPY_AND_ASSIGN(Device);
};
« no previous file with comments | « src/cashew_unittest.cc ('k') | src/device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698