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

Side by Side Diff: dbus/bus.h

Issue 12224139: Supporting callback for Disconnected signal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | dbus/end_to_end_async_unittest.cc » ('J')
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Creates a Bus object. The actual connection will be established when 195 // Creates a Bus object. The actual connection will be established when
196 // Connect() is called. 196 // Connect() is called.
197 explicit Bus(const Options& options); 197 explicit Bus(const Options& options);
198 198
199 // Called when an ownership request is complete. 199 // Called when an ownership request is complete.
200 // Parameters: 200 // Parameters:
201 // - the requested service name. 201 // - the requested service name.
202 // - whether ownership has been obtained or not. 202 // - whether ownership has been obtained or not.
203 typedef base::Callback<void (const std::string&, bool)> OnOwnershipCallback; 203 typedef base::Callback<void (const std::string&, bool)> OnOwnershipCallback;
204
205 // Called when the connection with dbus-daemon is closed. This function is
206 // also called when the connection is closed by ShutdownAndBlock. |callback|
207 // can be null callback.
208 typedef base::Callback<void ()> OnDisconnectedCallback;
satorux1 2013/02/13 08:06:53 I think you can just use base::Closure because thi
Seigo Nonaka 2013/02/13 09:45:29 Done.
209 void SetDisconnectedCallback(const OnDisconnectedCallback& callback);
210
204 // TODO(satorux): Remove the service name parameter as the caller of 211 // TODO(satorux): Remove the service name parameter as the caller of
205 // RequestOwnership() knows the service name. 212 // RequestOwnership() knows the service name.
206 213
207 // Gets the object proxy for the given service name and the object path. 214 // Gets the object proxy for the given service name and the object path.
208 // The caller must not delete the returned object. 215 // The caller must not delete the returned object.
209 // 216 //
210 // Returns an existing object proxy if the bus object already owns the 217 // Returns an existing object proxy if the bus object already owns the
211 // object proxy for the given service name and the object path. 218 // object proxy for the given service name and the object path.
212 // Never returns NULL. 219 // Never returns NULL.
213 // 220 //
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 491
485 // Returns true if the bus is connected to D-Bus. 492 // Returns true if the bus is connected to D-Bus.
486 bool is_connected() { return connection_ != NULL; } 493 bool is_connected() { return connection_ != NULL; }
487 494
488 protected: 495 protected:
489 // This is protected, so we can define sub classes. 496 // This is protected, so we can define sub classes.
490 virtual ~Bus(); 497 virtual ~Bus();
491 498
492 private: 499 private:
493 friend class base::RefCountedThreadSafe<Bus>; 500 friend class base::RefCountedThreadSafe<Bus>;
501 friend class DisconnectableBusForTesting;
satorux1 2013/02/13 08:06:53 This worries me because 1) 'friend' should be avo
Seigo Nonaka 2013/02/13 09:45:29 Sure, adding CloseConnection. Thanks.
494 502
495 // Helper function used for RemoveObjectProxy(). 503 // Helper function used for RemoveObjectProxy().
496 void RemoveObjectProxyInternal(scoped_refptr<dbus::ObjectProxy> object_proxy, 504 void RemoveObjectProxyInternal(scoped_refptr<dbus::ObjectProxy> object_proxy,
497 const base::Closure& callback); 505 const base::Closure& callback);
498 506
499 // Helper function used for UnregisterExportedObject(). 507 // Helper function used for UnregisterExportedObject().
500 void UnregisterExportedObjectInternal( 508 void UnregisterExportedObjectInternal(
501 scoped_refptr<dbus::ExportedObject> exported_object); 509 scoped_refptr<dbus::ExportedObject> exported_object);
502 510
503 // Helper function used for ShutdownOnDBusThreadAndBlock(). 511 // Helper function used for ShutdownOnDBusThreadAndBlock().
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 602
595 bool async_operations_set_up_; 603 bool async_operations_set_up_;
596 bool shutdown_completed_; 604 bool shutdown_completed_;
597 605
598 // Counters to make sure that OnAddWatch()/OnRemoveWatch() and 606 // Counters to make sure that OnAddWatch()/OnRemoveWatch() and
599 // OnAddTimeout()/OnRemoveTimeou() are balanced. 607 // OnAddTimeout()/OnRemoveTimeou() are balanced.
600 int num_pending_watches_; 608 int num_pending_watches_;
601 int num_pending_timeouts_; 609 int num_pending_timeouts_;
602 610
603 std::string address_; 611 std::string address_;
612 OnDisconnectedCallback on_disconnected_callback_;
604 613
605 DISALLOW_COPY_AND_ASSIGN(Bus); 614 DISALLOW_COPY_AND_ASSIGN(Bus);
606 }; 615 };
607 616
608 } // namespace dbus 617 } // namespace dbus
609 618
610 #endif // DBUS_BUS_H_ 619 #endif // DBUS_BUS_H_
OLDNEW
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | dbus/end_to_end_async_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698