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

Side by Side Diff: dbus/bus.h

Issue 12088068: DBus: Bus::AddMatch and RemoveMatch support repeated rules. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: RemoveMatch returns a bool. Created 7 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
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BUS_H_ 5 #ifndef DBUS_BUS_H_
6 #define DBUS_BUS_H_ 6 #define DBUS_BUS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 virtual bool RemoveFilterFunction(DBusHandleMessageFunction filter_function, 360 virtual bool RemoveFilterFunction(DBusHandleMessageFunction filter_function,
361 void* user_data); 361 void* user_data);
362 362
363 // Adds the match rule. Messages that match the rule will be processed 363 // Adds the match rule. Messages that match the rule will be processed
364 // by the filter functions added by AddFilterFunction(). 364 // by the filter functions added by AddFilterFunction().
365 // 365 //
366 // You cannot specify which filter function to use for a match rule. 366 // You cannot specify which filter function to use for a match rule.
367 // Instead, you should check if an incoming message is what you are 367 // Instead, you should check if an incoming message is what you are
368 // interested in, in the filter functions. 368 // interested in, in the filter functions.
369 // 369 //
370 // The same match rule can be added more than once, but ignored from the 370 // The same match rule can be added more than once and should be removed
371 // second time. 371 // as many times as it was added.
372 // 372 //
373 // The match rule looks like: 373 // The match rule looks like:
374 // "type='signal', interface='org.chromium.SomeInterface'". 374 // "type='signal', interface='org.chromium.SomeInterface'".
375 // 375 //
376 // See "Message Bus Message Routing" section in the D-Bus specification 376 // See "Message Bus Message Routing" section in the D-Bus specification
377 // for details about match rules: 377 // for details about match rules:
378 // http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing 378 // http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing
379 // 379 //
380 // BLOCKING CALL. 380 // BLOCKING CALL.
381 virtual void AddMatch(const std::string& match_rule, DBusError* error); 381 virtual void AddMatch(const std::string& match_rule, DBusError* error);
382 382
383 // Removes the match rule previously added by AddMatch(). 383 // Removes the match rule previously added by AddMatch().
384 // Returns false if the requested match rule is unknown or has already been
385 // removed. Otherwise, returns true and sets |error| accordingly.
384 // 386 //
385 // BLOCKING CALL. 387 // BLOCKING CALL.
386 virtual void RemoveMatch(const std::string& match_rule, DBusError* error); 388 virtual bool RemoveMatch(const std::string& match_rule, DBusError* error);
387 389
388 // Tries to register the object path. Returns true on success. 390 // Tries to register the object path. Returns true on success.
389 // Returns false if the object path is already registered. 391 // Returns false if the object path is already registered.
390 // 392 //
391 // |message_function| in |vtable| will be called every time when a new 393 // |message_function| in |vtable| will be called every time when a new
392 // |message sent to the object path arrives. 394 // |message sent to the object path arrives.
393 // 395 //
394 // The same object path must not be added more than once. 396 // The same object path must not be added more than once.
395 // 397 //
396 // See also documentation of |dbus_connection_try_register_object_path| at 398 // See also documentation of |dbus_connection_try_register_object_path| at
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; 512 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_;
511 base::WaitableEvent on_shutdown_; 513 base::WaitableEvent on_shutdown_;
512 DBusConnection* connection_; 514 DBusConnection* connection_;
513 515
514 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; 516 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
515 base::PlatformThreadId origin_thread_id_; 517 base::PlatformThreadId origin_thread_id_;
516 518
517 std::set<std::string> owned_service_names_; 519 std::set<std::string> owned_service_names_;
518 // The following sets are used to check if rules/object_paths/filters 520 // The following sets are used to check if rules/object_paths/filters
519 // are properly cleaned up before destruction of the bus object. 521 // are properly cleaned up before destruction of the bus object.
520 std::set<std::string> match_rules_added_; 522 // Since it's not an error to add the same match rule twice, the repeated
523 // match rules are counted in a map.
524 std::map<std::string, int> match_rules_added_;
521 std::set<ObjectPath> registered_object_paths_; 525 std::set<ObjectPath> registered_object_paths_;
522 std::set<std::pair<DBusHandleMessageFunction, void*> > 526 std::set<std::pair<DBusHandleMessageFunction, void*> >
523 filter_functions_added_; 527 filter_functions_added_;
524 528
525 // ObjectProxyTable is used to hold the object proxies created by the 529 // ObjectProxyTable is used to hold the object proxies created by the
526 // bus object. Key is a pair; the first part is a concatenated string of 530 // bus object. Key is a pair; the first part is a concatenated string of
527 // service name + object path, like 531 // service name + object path, like
528 // "org.chromium.TestService/org/chromium/TestObject". 532 // "org.chromium.TestService/org/chromium/TestObject".
529 // The second part is the ObjectProxy::Options for the proxy. 533 // The second part is the ObjectProxy::Options for the proxy.
530 typedef std::map<std::pair<std::string, int>, 534 typedef std::map<std::pair<std::string, int>,
(...skipping 16 matching lines...) Expand all
547 int num_pending_timeouts_; 551 int num_pending_timeouts_;
548 552
549 std::string address_; 553 std::string address_;
550 554
551 DISALLOW_COPY_AND_ASSIGN(Bus); 555 DISALLOW_COPY_AND_ASSIGN(Bus);
552 }; 556 };
553 557
554 } // namespace dbus 558 } // namespace dbus
555 559
556 #endif // DBUS_BUS_H_ 560 #endif // DBUS_BUS_H_
OLDNEW
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698