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

Side by Side Diff: src/service_manager.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: Address more djkurtz review comments 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_SERVICE_MANAGER_H_ 5 #ifndef SRC_SERVICE_MANAGER_H_
6 #define SRC_SERVICE_MANAGER_H_ 6 #define SRC_SERVICE_MANAGER_H_
7 7
8 #include <glib.h>
9
8 #include <map> 10 #include <map>
9 #include <string> 11 #include <string>
10 #include <vector> 12 #include <vector>
11 13
12 #include <base/basictypes.h> // NOLINT 14 #include <base/basictypes.h> // NOLINT
13 #include <dbus-c++/dbus.h> // NOLINT 15 #include <dbus-c++/dbus.h> // NOLINT
14 16
15 #include "src/flimflam_manager_client_glue.h" 17 #include "src/flimflam_manager_client_glue.h"
16 #include "src/service.h" 18 #include "src/service.h"
17 19
18 namespace cashew { 20 namespace cashew {
19 21
20 class CashewServer; 22 class CashewServer;
21 23
22 // map of service path names to Service objects 24 // map of service path names to Service objects
23 typedef std::map<std::string, Service*> ServiceMap; 25 typedef std::map<std::string, Service*> ServiceMap;
24 26
27 // vector of Service objects
28 typedef std::vector<Service*> ServiceList;
29
25 // vector of DBus::Path objects (strings) representing service path names 30 // vector of DBus::Path objects (strings) representing service path names
26 typedef std::vector<DBus::Path> ServicePathList; 31 typedef std::vector<DBus::Path> ServicePathList;
27 32
28 // monitors Flimflam and maintains a collection of cellular service objects 33 // monitors Flimflam and maintains a collection of cellular service objects
29 class ServiceManager : public org::chromium::flimflam::Manager_proxy, 34 class ServiceManager : public org::chromium::flimflam::Manager_proxy,
30 public DBus::IntrospectableProxy, 35 public DBus::IntrospectableProxy,
31 public DBus::ObjectProxy { 36 public DBus::ObjectProxy {
32 public: 37 public:
33 explicit ServiceManager(DBus::Connection& connection); // NOLINT 38 explicit ServiceManager(DBus::Connection& connection, // NOLINT
39 GMainLoop * const main_loop);
34 virtual ~ServiceManager(); 40 virtual ~ServiceManager();
35 41
36 // look up a service by its path name 42 // look up a service by its path name
37 // returns NULL if service is not found 43 // returns NULL if service is not found
38 virtual const Service* GetService(const std::string& service_path) const; 44 virtual const Service* GetService(const std::string& service_path) const;
39 45
40 // set Cashew server 46 // set Cashew server
41 // we'll talk to it when we want to emit updates to the world on behalf of 47 // we'll talk to it when we want to emit updates to the world on behalf of
42 // our child Services. 48 // our child Services.
43 // it's ok to clear this by setting it to NULL, in which case our updates 49 // it's ok to clear this by setting it to NULL, in which case our updates
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 91
86 // set idle/timer source id 92 // set idle/timer source id
87 virtual void SetGetPropertiesSourceId(guint source_id); 93 virtual void SetGetPropertiesSourceId(guint source_id);
88 94
89 // are we in the process of retrying our GetProperties call? 95 // are we in the process of retrying our GetProperties call?
90 virtual bool RetryingGetProperties() const; 96 virtual bool RetryingGetProperties() const;
91 97
92 // set the retrying flag 98 // set the retrying flag
93 virtual void OnRetryingGetProperties(bool retrying); 99 virtual void OnRetryingGetProperties(bool retrying);
94 100
101 // get deferred service deletion source id
102 virtual guint GetDeferredServiceDeletionSourceId() const;
103
104 // set deferred service deletion source id
105 virtual void SetDeferredServiceDeletionSourceId(guint source_id);
106
95 private: 107 private:
96 // D-Bus connection owned by our creator 108 // D-Bus connection owned by our creator
97 // shared with Service objs that we create 109 // shared with Service objs that we create
98 DBus::Connection& connection_; 110 DBus::Connection& connection_;
99 111
112 // glib main loop
113 GMainLoop * const main_loop_;
114
100 // collection of Service objs representing cellular services 115 // collection of Service objs representing cellular services
101 ServiceMap services_; 116 ServiceMap services_;
102 117
103 // Cashew server implementing our front-end interface 118 // Cashew server implementing our front-end interface
104 CashewServer *cashew_server_; 119 CashewServer *cashew_server_;
105 120
106 // default technology most recently reported by Flimflam 121 // default technology most recently reported by Flimflam
107 Service::Type default_technology_; 122 Service::Type default_technology_;
108 123
109 // the cellular service, if any, that we think is the default service 124 // the cellular service, if any, that we think is the default service
110 // can be NULL if we don't know the default service or a non-cellular 125 // can be NULL if we don't know the default service or a non-cellular
111 // service is the default 126 // service is the default
112 Service *default_cellular_service_; 127 Service *default_cellular_service_;
113 128
114 // global connectivity state most recently reported by Flimflam 129 // global connectivity state most recently reported by Flimflam
115 ConnectivityState connectivity_state_; 130 ConnectivityState connectivity_state_;
116 131
117 // GetProperties timer glib source id 132 // GetProperties timer glib source id
118 // 0 means no source 133 // 0 means no source
119 guint get_properties_source_id_; 134 guint get_properties_source_id_;
120 135
121 // are we in the process of retrying our GetProperties call? 136 // are we in the process of retrying our GetProperties call?
122 // this flag exists to distinguish between our initial g_idle_add call 137 // this flag exists to distinguish between our initial g_idle_add call
123 // and our subsequent timer calls 138 // and our subsequent timer calls
124 bool retrying_get_properties_; 139 bool retrying_get_properties_;
125 140
141 // Service objects pending deletion from the main loop
142 // we need to do this to work around a dbus-c++ deadlock issue that arises
143 // when we send a D-Bus message from a D-Bus callback
144 ServiceList services_pending_deletion_;
145
146 // glib source id for deferred service deletion
147 guint deferred_service_deletion_source_id_;
148
126 // delete a collection of services 149 // delete a collection of services
127 void DeleteServices(ServiceMap *service_map); 150 // deletes services immediately if |defer| == false
151 // schedules services for later deletion if |defer| == true
152 void DeleteServices(ServiceMap *service_map, bool defer);
153
154 // deletes members of |services_pending_deletion_| immediately
155 void DeletePendingServices();
156
157 // schedule service for later deletion from the main loop
158 void ScheduleServiceForLaterDeletion(Service *service);
159
160 // glib integration: static wrapper for DeletePendingServices
161 // takes object ptr as data and invokes object->DeletePendingServices()
162 // does not reschedule itself to run again
163 static gboolean StaticDeletePendingServicesCallback(gpointer data);
128 164
129 // glib integration: static wrapper for GetFlimflamProperties 165 // glib integration: static wrapper for GetFlimflamProperties
130 // takes object ptr as data and invokes object->GetFlimflamProperties() 166 // takes object ptr as data and invokes object->GetFlimflamProperties()
131 static gboolean StaticGetFlimflamPropertiesCallback(gpointer data); 167 static gboolean StaticGetFlimflamPropertiesCallback(gpointer data);
132 168
133 // get interesting properties from Flimflam such as Services and 169 // get interesting properties from Flimflam such as Services and
134 // DefaultTechnology 170 // DefaultTechnology
135 // returns true on success and false on failure 171 // returns true on success and false on failure
136 bool GetFlimflamProperties(); 172 bool GetFlimflamProperties();
137 173
(...skipping 30 matching lines...) Expand all
168 204
169 // Flimflam has told us that it has gone offline 205 // Flimflam has told us that it has gone offline
170 void OnFlimflamOffline(); 206 void OnFlimflamOffline();
171 207
172 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 208 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
173 }; 209 };
174 210
175 } // namespace cashew 211 } // namespace cashew
176 212
177 #endif // SRC_SERVICE_MANAGER_H_ 213 #endif // SRC_SERVICE_MANAGER_H_
OLDNEW
« src/main.cc ('K') | « src/service.cc ('k') | src/service_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698