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

Side by Side Diff: src/device_impl.h

Issue 6395007: cashew: gmock integration (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/device.cc ('k') | src/device_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010, 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SRC_DEVICE_IMPL_H_
6 #define SRC_DEVICE_IMPL_H_
7
8 #include <glib.h>
9
10 #include <string>
11
12 #include <base/basictypes.h> // NOLINT
13 #include <dbus-c++/dbus.h> // NOLINT
14
15 #include "src/byte_counter.h"
16 #include "src/device.h"
17 #include "src/flimflam_device_client_glue.h"
18 #include "src/property_changed_handler.h"
19
20 namespace cashew {
21
22 // represents a cellular device and monitors Flimflam state for that device
23 class DeviceImpl : public Device,
24 public org::chromium::flimflam::Device_proxy,
25 public DBus::IntrospectableProxy,
26 public DBus::ObjectProxy,
27 public ByteCounterDelegate,
28 public PropertyChangedDelegate {
29 public:
30 DeviceImpl(Service * const parent, DBus::Connection& connection, // NOLINT
31 const DBus::Path& path);
32 virtual ~DeviceImpl();
33
34 // Device methods
35 virtual const DBus::Path& GetPath() const;
36 virtual Type GetType() const;
37 virtual const std::string& GetCarrier() const;
38 virtual const std::string& GetInterface() const;
39
40 // Flimflam Device D-Bus Proxy methods
41
42 // receive incoming PropertyChanged D-Bus signal from Flimflam device and
43 // schedule deferred processing
44 virtual void PropertyChanged(const std::string& property_name,
45 const DBus::Variant& new_value);
46
47 // PropertyChangedDelegate methods
48
49 virtual void OnPropertyChanged(const PropertyChangedHandler *handler,
50 const std::string& property_name,
51 const DBus::Variant& new_value);
52
53 // Service methods
54 virtual bool StartByteCounter();
55 virtual void StopByteCounter();
56 virtual bool ByteCounterRunning() const;
57
58 // ByteCounterDelegate methods
59
60 // called when bye counter is updated
61 virtual void OnByteCounterUpdate(const ByteCounter *counter,
62 uint64 rx_bytes, uint64 tx_bytes);
63
64 private:
65 // back pointer to our parent Service
66 Service * const parent_;
67
68 // D-Bus path for Flimflam device that we represent
69 // this is our unique identifier
70 const DBus::Path path_;
71
72 // device type
73 Type type_;
74
75 // cellular carrier
76 std::string carrier_;
77
78 // interface name
79 std::string interface_;
80
81 // GetProperties timer glib source id
82 // 0 means no source
83 guint get_properties_source_id_;
84
85 // are we in the process of retrying our GetProperties call?
86 // this flag exists to distinguish between our initial g_idle_add call
87 // and our subsequent timer calls
88 bool retrying_get_properties_;
89
90 // byte counter for this device
91 // can be NULL
92 ByteCounter *byte_counter_;
93
94 // is the byte counter running?
95 // this is distinct from whether or not byte_counter_ == NULL, since the
96 // counter may be logically running but we may not yet know our interface
97 // name and therefore may not yet have created a byte counter object.
98 bool byte_counter_running_;
99
100 // Handler for deferred processing of D-Bus PropertyChanged signals.
101 // See comments in service_manager.h
102 PropertyChangedHandler property_changed_handler_;
103
104 // convert type string to Type enum value
105 Type TypeFromString(const std::string& type) const;
106
107 // we've received updated Cellular.Carrier info from Flimflam
108 void OnCarrierUpdate(const std::string& carrier);
109
110 // we've received updated Interface info from Flimflam
111 void OnInterfaceUpdate(const std::string& interface);
112
113 // we've received updated Type info from Flimflam
114 void OnTypeUpdate(const std::string& type);
115
116 // glib integration: static wrapper for GetDeviceProperties
117 // takes object ptr as data and invokes object->GetDeviceProperties
118 static gboolean StaticGetDevicePropertiesCallback(gpointer data);
119
120 // get device properties from Flimflam
121 // returns true on success and false on failure
122 bool GetDeviceProperties();
123
124 // create a byte counter object and assign it to |byte_counter_|
125 bool CreateByteCounter();
126
127 // delete byte counter object pointed to by |byte_counter_| if any
128 void DeleteByteCounter();
129
130 DISALLOW_COPY_AND_ASSIGN(DeviceImpl);
131 };
132
133 } // namespace cashew
134
135 #endif // SRC_DEVICE_IMPL_H_
OLDNEW
« no previous file with comments | « src/device.cc ('k') | src/device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698