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

Side by Side Diff: dbus/object_proxy.h

Issue 11199007: Add sender verification of D-Bus signals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove unnecessary code. Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 DBUS_OBJECT_PROXY_H_ 5 #ifndef DBUS_OBJECT_PROXY_H_
6 #define DBUS_OBJECT_PROXY_H_ 6 #define DBUS_OBJECT_PROXY_H_
7 7
8 #include <dbus/dbus.h> 8 #include <dbus/dbus.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void OnConnected(OnConnectedCallback on_connected_callback, 207 void OnConnected(OnConnectedCallback on_connected_callback,
208 const std::string& interface_name, 208 const std::string& interface_name,
209 const std::string& signal_name, 209 const std::string& signal_name,
210 bool success); 210 bool success);
211 211
212 // Handles the incoming request messages and dispatches to the signal 212 // Handles the incoming request messages and dispatches to the signal
213 // callbacks. 213 // callbacks.
214 DBusHandlerResult HandleMessage(DBusConnection* connection, 214 DBusHandlerResult HandleMessage(DBusConnection* connection,
215 DBusMessage* raw_message); 215 DBusMessage* raw_message);
216 216
217 // Verifies the sender, checks if we know about the signal, and invokes the
218 // callback if any.
219 DBusHandlerResult VerifySenderAndDispatch(scoped_ptr<dbus::Signal> signal);
220
217 // Runs the method. Helper function for HandleMessage(). 221 // Runs the method. Helper function for HandleMessage().
218 void RunMethod(base::TimeTicks start_time, 222 void RunMethod(base::TimeTicks start_time,
219 SignalCallback signal_callback, 223 SignalCallback signal_callback,
220 Signal* signal); 224 Signal* signal);
221 225
222 // Redirects the function call to HandleMessage(). 226 // Redirects the function call to HandleMessage().
223 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, 227 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection,
224 DBusMessage* raw_message, 228 DBusMessage* raw_message,
225 void* user_data); 229 void* user_data);
226 230
227 // Helper method for logging response errors appropriately. 231 // Helper method for logging response errors appropriately.
228 void LogMethodCallFailure(const base::StringPiece& interface_name, 232 void LogMethodCallFailure(const base::StringPiece& interface_name,
229 const base::StringPiece& method_name, 233 const base::StringPiece& method_name,
230 const base::StringPiece& error_name, 234 const base::StringPiece& error_name,
231 const base::StringPiece& error_message) const; 235 const base::StringPiece& error_message) const;
232 236
233 // Used as ErrorCallback by CallMethod(). 237 // Used as ErrorCallback by CallMethod().
234 void OnCallMethodError(const std::string& interface_name, 238 void OnCallMethodError(const std::string& interface_name,
235 const std::string& method_name, 239 const std::string& method_name,
236 ResponseCallback response_callback, 240 ResponseCallback response_callback,
237 ErrorResponse* error_response); 241 ErrorResponse* error_response);
238 242
243 // Adds the match rule to the bus and associate the callback with the signal.
244 bool AddMatchRuleWithCallback(const std::string& match_rule,
245 const std::string& absolute_signal_name,
246 SignalCallback signal_callback);
247
248 // Adds the match rule to the bus so that HandleMessage can see the signal.
249 bool AddMatchRuleWithoutCallback(const std::string& match_rule,
250 const std::string& absolute_signal_name);
251
252 // Calls D-Bus's GetNameOwner method asynchronously to update the owner of
253 // |service_name_|.
254 DBusHandlerResult UpdateNameOwnerAsync(scoped_ptr<Signal> pending_signal);
255
256 // Handles NameOwnerChanged signal from D-Bus's special message bus.
257 DBusHandlerResult HandleNameOwnerChanged(dbus::Signal* signal);
258
259 // Helper Processes the response of GetNameOwner method call.
260 void OnGetNameOwner(Signal* signal, Response* callback);
261
262 // Helper function for OnGetNameOwner.
263 void OnGetNameOwnerOnDbusThread(Signal* signal, Response* callback);
264
265 // Processes the error response of GetNameOwner method call.
266 void OnGetNameOwnerError(Signal* signal, ErrorResponse* callback);
267
268 // Helper function for OnGetNameOwnerError.
269 void OnGetNameOwnerErrorOnDbusThread(Signal* signal, ErrorResponse* callback);
270
239 scoped_refptr<Bus> bus_; 271 scoped_refptr<Bus> bus_;
240 std::string service_name_; 272 std::string service_name_;
241 ObjectPath object_path_; 273 ObjectPath object_path_;
242 274
243 // True if the message filter was added. 275 // True if the message filter was added.
244 bool filter_added_; 276 bool filter_added_;
245 277
246 // The method table where keys are absolute signal names (i.e. interface 278 // The method table where keys are absolute signal names (i.e. interface
247 // name + signal name), and values are the corresponding callbacks. 279 // name + signal name), and values are the corresponding callbacks.
248 typedef std::map<std::string, SignalCallback> MethodTable; 280 typedef std::map<std::string, SignalCallback> MethodTable;
249 MethodTable method_table_; 281 MethodTable method_table_;
250 282
251 std::set<std::string> match_rules_; 283 std::set<std::string> match_rules_;
252 284
253 const bool ignore_service_unknown_errors_; 285 const bool ignore_service_unknown_errors_;
254 286
287 // Known name owner of the well-known bus name represnted by |service_name_|.
288 std::string service_name_owner_;
289
255 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); 290 DISALLOW_COPY_AND_ASSIGN(ObjectProxy);
256 }; 291 };
257 292
258 } // namespace dbus 293 } // namespace dbus
259 294
260 #endif // DBUS_OBJECT_PROXY_H_ 295 #endif // DBUS_OBJECT_PROXY_H_
OLDNEW
« no previous file with comments | « dbus/dbus.gyp ('k') | dbus/object_proxy.cc » ('j') | dbus/object_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698