OLD | NEW |
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // EXAMPLE USAGE: | 183 // EXAMPLE USAGE: |
184 // dbus::Bus::Options options; | 184 // dbus::Bus::Options options; |
185 // options.bus_type = CUSTOM_ADDRESS; | 185 // options.bus_type = CUSTOM_ADDRESS; |
186 // options.address.assign("unix:path=/tmp/dbus-XXXXXXX"); | 186 // options.address.assign("unix:path=/tmp/dbus-XXXXXXX"); |
187 // // Set up other options | 187 // // Set up other options |
188 // dbus::Bus bus(options); | 188 // dbus::Bus bus(options); |
189 // | 189 // |
190 // // Do something. | 190 // // Do something. |
191 // | 191 // |
192 std::string address; | 192 std::string address; |
| 193 |
| 194 // If the connection with dbus-daemon is closed, |disconnected_callback| |
| 195 // will be called on the origin thread. This is also called when the |
| 196 // disonnection by ShutdownAndBlock. |disconnected_callback| can be null |
| 197 // callback |
| 198 base::Closure disconnected_callback; |
193 }; | 199 }; |
194 | 200 |
195 // Creates a Bus object. The actual connection will be established when | 201 // Creates a Bus object. The actual connection will be established when |
196 // Connect() is called. | 202 // Connect() is called. |
197 explicit Bus(const Options& options); | 203 explicit Bus(const Options& options); |
198 | 204 |
199 // Called when an ownership request is complete. | 205 // Called when an ownership request is complete. |
200 // Parameters: | 206 // Parameters: |
201 // - the requested service name. | 207 // - the requested service name. |
202 // - whether ownership has been obtained or not. | 208 // - whether ownership has been obtained or not. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // The public functions below are not intended to be used in client | 328 // The public functions below are not intended to be used in client |
323 // code. These are used to implement ObjectProxy and ExportedObject. | 329 // code. These are used to implement ObjectProxy and ExportedObject. |
324 // | 330 // |
325 | 331 |
326 // Connects the bus to the dbus-daemon. | 332 // Connects the bus to the dbus-daemon. |
327 // Returns true on success, or the bus is already connected. | 333 // Returns true on success, or the bus is already connected. |
328 // | 334 // |
329 // BLOCKING CALL. | 335 // BLOCKING CALL. |
330 virtual bool Connect(); | 336 virtual bool Connect(); |
331 | 337 |
| 338 // Disconnects the bus from the dbus-daemon. |
| 339 // Safe to call multiple times and no operation after the first call. |
| 340 // Do not call for shared connection it will be released by libdbus. |
| 341 // |
| 342 // BLOCKING CALL. |
| 343 virtual void ClosePrivateConnection(); |
| 344 |
332 // Requests the ownership of the service name given by |service_name|. | 345 // Requests the ownership of the service name given by |service_name|. |
333 // See also RequestOwnershipAndBlock(). | 346 // See also RequestOwnershipAndBlock(). |
334 // | 347 // |
335 // |on_ownership_callback| is called when the service name is obtained | 348 // |on_ownership_callback| is called when the service name is obtained |
336 // or failed to be obtained, in the origin thread. | 349 // or failed to be obtained, in the origin thread. |
337 // | 350 // |
338 // Must be called in the origin thread. | 351 // Must be called in the origin thread. |
339 virtual void RequestOwnership(const std::string& service_name, | 352 virtual void RequestOwnership(const std::string& service_name, |
340 OnOwnershipCallback on_ownership_callback); | 353 OnOwnershipCallback on_ownership_callback); |
341 | 354 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 607 |
595 bool async_operations_set_up_; | 608 bool async_operations_set_up_; |
596 bool shutdown_completed_; | 609 bool shutdown_completed_; |
597 | 610 |
598 // Counters to make sure that OnAddWatch()/OnRemoveWatch() and | 611 // Counters to make sure that OnAddWatch()/OnRemoveWatch() and |
599 // OnAddTimeout()/OnRemoveTimeou() are balanced. | 612 // OnAddTimeout()/OnRemoveTimeou() are balanced. |
600 int num_pending_watches_; | 613 int num_pending_watches_; |
601 int num_pending_timeouts_; | 614 int num_pending_timeouts_; |
602 | 615 |
603 std::string address_; | 616 std::string address_; |
| 617 base::Closure on_disconnected_closure_; |
604 | 618 |
605 DISALLOW_COPY_AND_ASSIGN(Bus); | 619 DISALLOW_COPY_AND_ASSIGN(Bus); |
606 }; | 620 }; |
607 | 621 |
608 } // namespace dbus | 622 } // namespace dbus |
609 | 623 |
610 #endif // DBUS_BUS_H_ | 624 #endif // DBUS_BUS_H_ |
OLD | NEW |