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 // TODO(satorux): | 5 // TODO(satorux): |
6 // - Handle "disconnected" signal. | 6 // - Handle "disconnected" signal. |
7 | 7 |
8 #include "dbus/bus.h" | 8 #include "dbus/bus.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "dbus/scoped_dbus_error.h" | 21 #include "dbus/scoped_dbus_error.h" |
22 | 22 |
23 namespace dbus { | 23 namespace dbus { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // The class is used for watching the file descriptor used for D-Bus | 27 // The class is used for watching the file descriptor used for D-Bus |
28 // communication. | 28 // communication. |
29 class Watch : public base::MessagePumpLibevent::Watcher { | 29 class Watch : public base::MessagePumpLibevent::Watcher { |
30 public: | 30 public: |
31 Watch(DBusWatch* watch) | 31 explicit Watch(DBusWatch* watch) |
32 : raw_watch_(watch) { | 32 : raw_watch_(watch) { |
33 dbus_watch_set_data(raw_watch_, this, NULL); | 33 dbus_watch_set_data(raw_watch_, this, NULL); |
34 } | 34 } |
35 | 35 |
36 virtual ~Watch() { | 36 virtual ~Watch() { |
37 dbus_watch_set_data(raw_watch_, NULL, NULL); | 37 dbus_watch_set_data(raw_watch_, NULL, NULL); |
38 } | 38 } |
39 | 39 |
40 // Returns true if the underlying file descriptor is ready to be watched. | 40 // Returns true if the underlying file descriptor is ready to be watched. |
41 bool IsReadyToBeWatched() { | 41 bool IsReadyToBeWatched() { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // The class is used for monitoring the timeout used for D-Bus method | 92 // The class is used for monitoring the timeout used for D-Bus method |
93 // calls. | 93 // calls. |
94 // | 94 // |
95 // Unlike Watch, Timeout is a ref counted object, to ensure that |this| of | 95 // Unlike Watch, Timeout is a ref counted object, to ensure that |this| of |
96 // the object is is alive when HandleTimeout() is called. It's unlikely | 96 // the object is is alive when HandleTimeout() is called. It's unlikely |
97 // but it may be possible that HandleTimeout() is called after | 97 // but it may be possible that HandleTimeout() is called after |
98 // Bus::OnRemoveTimeout(). That's why we don't simply delete the object in | 98 // Bus::OnRemoveTimeout(). That's why we don't simply delete the object in |
99 // Bus::OnRemoveTimeout(). | 99 // Bus::OnRemoveTimeout(). |
100 class Timeout : public base::RefCountedThreadSafe<Timeout> { | 100 class Timeout : public base::RefCountedThreadSafe<Timeout> { |
101 public: | 101 public: |
102 Timeout(DBusTimeout* timeout) | 102 explicit Timeout(DBusTimeout* timeout) |
103 : raw_timeout_(timeout), | 103 : raw_timeout_(timeout), |
104 monitoring_is_active_(false), | 104 monitoring_is_active_(false), |
105 is_completed(false) { | 105 is_completed(false) { |
106 dbus_timeout_set_data(raw_timeout_, this, NULL); | 106 dbus_timeout_set_data(raw_timeout_, this, NULL); |
107 AddRef(); // Balanced on Complete(). | 107 AddRef(); // Balanced on Complete(). |
108 } | 108 } |
109 | 109 |
110 // Returns true if the timeout is ready to be monitored. | 110 // Returns true if the timeout is ready to be monitored. |
111 bool IsReadyToBeMonitored() { | 111 bool IsReadyToBeMonitored() { |
112 return dbus_timeout_get_enabled(raw_timeout_); | 112 return dbus_timeout_get_enabled(raw_timeout_); |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 } | 843 } |
844 | 844 |
845 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, | 845 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, |
846 DBusDispatchStatus status, | 846 DBusDispatchStatus status, |
847 void* data) { | 847 void* data) { |
848 Bus* self = static_cast<Bus*>(data); | 848 Bus* self = static_cast<Bus*>(data); |
849 self->OnDispatchStatusChanged(connection, status); | 849 self->OnDispatchStatusChanged(connection, status); |
850 } | 850 } |
851 | 851 |
852 } // namespace dbus | 852 } // namespace dbus |
OLD | NEW |