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

Side by Side Diff: src/device.h

Issue 5380002: cashew: defer all D-Bus signal processing to main loop (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SRC_DEVICE_H_ 5 #ifndef SRC_DEVICE_H_
6 #define SRC_DEVICE_H_ 6 #define SRC_DEVICE_H_
7 7
8 #include <glib.h> 8 #include <glib.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include <base/basictypes.h> // NOLINT 12 #include <base/basictypes.h> // NOLINT
13 #include <dbus-c++/dbus.h> // NOLINT 13 #include <dbus-c++/dbus.h> // NOLINT
14 14
15 #include "src/byte_counter.h" 15 #include "src/byte_counter.h"
16 #include "src/flimflam_device_client_glue.h" 16 #include "src/flimflam_device_client_glue.h"
17 #include "src/property_changed_handler.h"
17 18
18 namespace cashew { 19 namespace cashew {
19 20
20 class ByteCounter; 21 class ByteCounter;
21 class Service; 22 class Service;
22 23
23 // represents a cellular device and monitors Flimflam state for that device 24 // represents a cellular device and monitors Flimflam state for that device
24 class Device : public org::chromium::flimflam::Device_proxy, 25 class Device : public org::chromium::flimflam::Device_proxy,
25 public DBus::IntrospectableProxy, 26 public DBus::IntrospectableProxy,
26 public DBus::ObjectProxy, 27 public DBus::ObjectProxy,
27 public ByteCounterDelegate { 28 public ByteCounterDelegate,
29 public PropertyChangedDelegate {
28 public: 30 public:
29 Device(Service * const parent, DBus::Connection& connection, // NOLINT 31 Device(Service * const parent, DBus::Connection& connection, // NOLINT
30 const DBus::Path& path); 32 const DBus::Path& path);
31 virtual ~Device(); 33 virtual ~Device();
32 34
33 // get D-Bus path for this device 35 // get D-Bus path for this device
34 virtual const DBus::Path& GetPath() const; 36 virtual const DBus::Path& GetPath() const;
35 37
36 // valid type values for this device 38 // valid type values for this device
37 typedef enum { 39 typedef enum {
(...skipping 14 matching lines...) Expand all
52 // get cellular carrier for this device 54 // get cellular carrier for this device
53 // returns empty string if we don't know 55 // returns empty string if we don't know
54 virtual const std::string& GetCarrier() const; 56 virtual const std::string& GetCarrier() const;
55 57
56 // get interface name for this device (e.g., "usb0") 58 // get interface name for this device (e.g., "usb0")
57 // returns empty string if we don't know 59 // returns empty string if we don't know
58 virtual const std::string& GetInterface() const; 60 virtual const std::string& GetInterface() const;
59 61
60 // Flimflam Device D-Bus Proxy methods 62 // Flimflam Device D-Bus Proxy methods
61 63
64 // receive incoming PropertyChanged D-Bus signal from Flimflam device and
65 // schedule deferred processing
62 virtual void PropertyChanged(const std::string& property_name, 66 virtual void PropertyChanged(const std::string& property_name,
63 const DBus::Variant& new_value); 67 const DBus::Variant& new_value);
64 68
69 // PropertyChangedDelegate methods
70
71 virtual void OnPropertyChanged(const PropertyChangedHandler *handler,
72 const std::string& property_name,
73 const DBus::Variant& new_value);
74
65 // Service methods 75 // Service methods
66 76
67 // start a new byte counter from 0 77 // start a new byte counter from 0
68 // there must not be an existing byte counter 78 // there must not be an existing byte counter
69 // |parent_| will receive periodic updates via Service::OnByteCounterUpdate 79 // |parent_| will receive periodic updates via Service::OnByteCounterUpdate
70 // returns true on success and false on failure 80 // returns true on success and false on failure
71 virtual bool StartByteCounter(); 81 virtual bool StartByteCounter();
72 82
73 // destroy any existing byte counter 83 // destroy any existing byte counter
74 // |parent_| will no longer receive updates after this call 84 // |parent_| will no longer receive updates after this call
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // byte counter for this device 136 // byte counter for this device
127 // can be NULL 137 // can be NULL
128 ByteCounter *byte_counter_; 138 ByteCounter *byte_counter_;
129 139
130 // is the byte counter running? 140 // is the byte counter running?
131 // this is distinct from whether or not byte_counter_ == NULL, since the 141 // this is distinct from whether or not byte_counter_ == NULL, since the
132 // counter may be logically running but we may not yet know our interface 142 // counter may be logically running but we may not yet know our interface
133 // name and therefore may not yet have created a byte counter object. 143 // name and therefore may not yet have created a byte counter object.
134 bool byte_counter_running_; 144 bool byte_counter_running_;
135 145
146 // Handler for deferred processing of D-Bus PropertyChanged signals.
147 // See comments in service_manager.h
148 PropertyChangedHandler property_changed_handler_;
149
136 // convert type string to Type enum value 150 // convert type string to Type enum value
137 Type TypeFromString(const std::string& type) const; 151 Type TypeFromString(const std::string& type) const;
138 152
139 // we've received updated Cellular.Carrier info from Flimflam 153 // we've received updated Cellular.Carrier info from Flimflam
140 void OnCarrierUpdate(const std::string& carrier); 154 void OnCarrierUpdate(const std::string& carrier);
141 155
142 // we've received updated Interface info from Flimflam 156 // we've received updated Interface info from Flimflam
143 void OnInterfaceUpdate(const std::string& interface); 157 void OnInterfaceUpdate(const std::string& interface);
144 158
145 // we've received updated Type info from Flimflam 159 // we've received updated Type info from Flimflam
(...skipping 12 matching lines...) Expand all
158 172
159 // delete byte counter object pointed to by |byte_counter_| if any 173 // delete byte counter object pointed to by |byte_counter_| if any
160 void DeleteByteCounter(); 174 void DeleteByteCounter();
161 175
162 DISALLOW_COPY_AND_ASSIGN(Device); 176 DISALLOW_COPY_AND_ASSIGN(Device);
163 }; 177 };
164 178
165 } // namespace cashew 179 } // namespace cashew
166 180
167 #endif // SRC_DEVICE_H_ 181 #endif // SRC_DEVICE_H_
OLDNEW
« no previous file with comments | « src/cashew_server.cc ('k') | src/device.cc » ('j') | src/property_changed_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698