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

Side by Side Diff: src/service.h

Issue 5333003: cashew: do not delete DBus::ObjectProxy objects from D-Bus callbacks (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 years, 1 month 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/main.cc ('k') | src/service.cc » ('j') | src/service.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo) 5 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo)
6 6
7 #ifndef SRC_SERVICE_H_ 7 #ifndef SRC_SERVICE_H_
8 #define SRC_SERVICE_H_ 8 #define SRC_SERVICE_H_
9 9
10 #include <glib.h> 10 #include <glib.h>
11 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector>
14 15
15 #include <base/basictypes.h> // NOLINT 16 #include <base/basictypes.h> // NOLINT
16 #include <dbus-c++/dbus.h> // NOLINT 17 #include <dbus-c++/dbus.h> // NOLINT
17 18
18 #include "src/data_plan.h" 19 #include "src/data_plan.h"
19 #include "src/data_plan_provider.h" 20 #include "src/data_plan_provider.h"
20 #include "src/flimflam_service_client_glue.h" 21 #include "src/flimflam_service_client_glue.h"
21 22
22 namespace cashew { 23 namespace cashew {
23 24
24 class Device; 25 class Device;
25 class Policy; 26 class Policy;
26 class ServiceManager; 27 class ServiceManager;
27 28
28 // map of key, value pairs representing service properties received via D-Bus 29 // map of key, value pairs representing service properties received via D-Bus
29 typedef std::map<std::string, DBus::Variant> PropertyMap; 30 typedef std::map<std::string, DBus::Variant> PropertyMap;
30 31
32 // vector of Device objects
33 typedef std::vector<Device*> DeviceList;
34
31 // represents a cellular service and monitors Flimflam state for that service 35 // represents a cellular service and monitors Flimflam state for that service
32 class Service : public org::chromium::flimflam::Service_proxy, 36 class Service : public org::chromium::flimflam::Service_proxy,
33 public DBus::IntrospectableProxy, 37 public DBus::IntrospectableProxy,
34 public DBus::ObjectProxy, 38 public DBus::ObjectProxy,
35 public DataPlanProviderDelegate { 39 public DataPlanProviderDelegate {
36 public: 40 public:
37 Service(ServiceManager * const parent, 41 Service(ServiceManager * const parent,
38 DBus::Connection& connection, // NOLINT 42 DBus::Connection& connection, // NOLINT
39 const DBus::Path& path); 43 const DBus::Path& path);
40 virtual ~Service(); 44 virtual ~Service();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 140
137 // set idle/timer source id 141 // set idle/timer source id
138 virtual void SetGetPropertiesSourceId(guint source_id); 142 virtual void SetGetPropertiesSourceId(guint source_id);
139 143
140 // are we in the process of retrying our GetProperties call? 144 // are we in the process of retrying our GetProperties call?
141 virtual bool RetryingGetProperties() const; 145 virtual bool RetryingGetProperties() const;
142 146
143 // set the retrying flag 147 // set the retrying flag
144 virtual void OnRetryingGetProperties(bool retrying); 148 virtual void OnRetryingGetProperties(bool retrying);
145 149
150 // get deferred device deletion source id
151 virtual guint GetDeferredDeviceDeletionSourceId() const;
152
153 // set deferred device deletion source id
154 virtual void SetDeferredDeviceDeletionSourceId(guint source_id);
155
146 private: 156 private:
147 // back pointer to our parent ServiceManager 157 // back pointer to our parent ServiceManager
148 ServiceManager * const parent_; 158 ServiceManager * const parent_;
149 159
150 // D-Bus connection, owned by our creator 160 // D-Bus connection, owned by our creator
151 // shared with Device obj that we create 161 // shared with Device obj that we create
152 DBus::Connection& connection_; 162 DBus::Connection& connection_;
153 163
154 // D-Bus path for Flimflam service that we represent 164 // D-Bus path for Flimflam service that we represent
155 // this is our unique identifier 165 // this is our unique identifier
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 202
193 // are we in the process of retrying our GetProperties call? 203 // are we in the process of retrying our GetProperties call?
194 // this flag exists to distinguish between our initial g_idle_add call 204 // this flag exists to distinguish between our initial g_idle_add call
195 // and our subsequent timer calls 205 // and our subsequent timer calls
196 bool retrying_get_properties_; 206 bool retrying_get_properties_;
197 207
198 // Service connectivity state 208 // Service connectivity state
199 // finer-grained connectivity info applicable when |state_| == kStateReady 209 // finer-grained connectivity info applicable when |state_| == kStateReady
200 ConnectivityState connectivity_state_; 210 ConnectivityState connectivity_state_;
201 211
212 // Device objects pending deletion from the main loop
213 // We need to do this to work around a dbus-c++ deadlock issue that arises
214 // when we send a D-Bus message from a D-Bus callback
215 DeviceList devices_pending_deletion_;
216
217 // glib source id for deferred device deletion
218 guint deferred_device_deletion_source_id_;
219
220 // deletes members of |devices_pending_deletion_| immediately
221 void DeletePendingDevices();
222
223 // schedule a device for later deletion from the main loop
224 void ScheduleDeviceForLaterDeletion(Device *device);
225
226 // glib integration: static wrapper for DeletePendingDevices
227 // takes object ptr as data and invokes object->DeletePendingDevices()
228 static gboolean StaticDeletePendingDevicesCallback(gpointer data);
229
202 // convert connectivity state string to ConnectivityState enum value 230 // convert connectivity state string to ConnectivityState enum value
203 static ConnectivityState ConnectivityStateFromString( 231 static ConnectivityState ConnectivityStateFromString(
204 const std::string& connectivity_state); 232 const std::string& connectivity_state);
205 233
206 // convert state string to State enum value 234 // convert state string to State enum value
207 static State StateFromString(const std::string& state); 235 static State StateFromString(const std::string& state);
208 236
209 // we've received updated Device info from Flimflam 237 // we've received updated Device info from Flimflam
210 void OnDeviceUpdate(const DBus::Path& device_path); 238 void OnDeviceUpdate(const DBus::Path& device_path);
211 239
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 327
300 // consult policy to determine if we should send an unsolicited update 328 // consult policy to determine if we should send an unsolicited update
301 void MaybeEmitDataPlansUpdate(); 329 void MaybeEmitDataPlansUpdate();
302 330
303 DISALLOW_COPY_AND_ASSIGN(Service); 331 DISALLOW_COPY_AND_ASSIGN(Service);
304 }; 332 };
305 333
306 } // namespace cashew 334 } // namespace cashew
307 335
308 #endif // SRC_SERVICE_H_ 336 #endif // SRC_SERVICE_H_
OLDNEW
« no previous file with comments | « src/main.cc ('k') | src/service.cc » ('j') | src/service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698