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

Side by Side Diff: dbus/bus.cc

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Also fix unit tests Created 4 years, 7 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 #include "dbus/bus.h" 5 #include "dbus/bus.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 CHECK(success) << "Unable to allocate memory"; 76 CHECK(success) << "Unable to allocate memory";
77 } 77 }
78 78
79 // Stops watching the underlying file descriptor. 79 // Stops watching the underlying file descriptor.
80 void StopWatching() { 80 void StopWatching() {
81 file_descriptor_watcher_.StopWatchingFileDescriptor(); 81 file_descriptor_watcher_.StopWatchingFileDescriptor();
82 } 82 }
83 83
84 private: 84 private:
85 // Implement MessagePumpLibevent::Watcher. 85 // Implement MessagePumpLibevent::Watcher.
86 void OnFileCanReadWithoutBlocking(int file_descriptor) override { 86 void OnFileCanReadWithoutBlocking(int /* file_descriptor */) override {
87 const bool success = dbus_watch_handle(raw_watch_, DBUS_WATCH_READABLE); 87 const bool success = dbus_watch_handle(raw_watch_, DBUS_WATCH_READABLE);
88 CHECK(success) << "Unable to allocate memory"; 88 CHECK(success) << "Unable to allocate memory";
89 } 89 }
90 90
91 // Implement MessagePumpLibevent::Watcher. 91 // Implement MessagePumpLibevent::Watcher.
92 void OnFileCanWriteWithoutBlocking(int file_descriptor) override { 92 void OnFileCanWriteWithoutBlocking(int /* file_descriptor */) override {
93 const bool success = dbus_watch_handle(raw_watch_, DBUS_WATCH_WRITABLE); 93 const bool success = dbus_watch_handle(raw_watch_, DBUS_WATCH_WRITABLE);
94 CHECK(success) << "Unable to allocate memory"; 94 CHECK(success) << "Unable to allocate memory";
95 } 95 }
96 96
97 DBusWatch* raw_watch_; 97 DBusWatch* raw_watch_;
98 base::MessagePumpLibevent::FileDescriptorWatcher file_descriptor_watcher_; 98 base::MessagePumpLibevent::FileDescriptorWatcher file_descriptor_watcher_;
99 }; 99 };
100 100
101 // The class is used for monitoring the timeout used for D-Bus method 101 // The class is used for monitoring the timeout used for D-Bus method
102 // calls. 102 // calls.
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 1088
1089 Timeout* timeout = static_cast<Timeout*>(dbus_timeout_get_data(raw_timeout)); 1089 Timeout* timeout = static_cast<Timeout*>(dbus_timeout_get_data(raw_timeout));
1090 if (timeout->IsReadyToBeMonitored()) { 1090 if (timeout->IsReadyToBeMonitored()) {
1091 timeout->StartMonitoring(this); 1091 timeout->StartMonitoring(this);
1092 } else { 1092 } else {
1093 timeout->StopMonitoring(); 1093 timeout->StopMonitoring();
1094 } 1094 }
1095 } 1095 }
1096 1096
1097 void Bus::OnDispatchStatusChanged(DBusConnection* connection, 1097 void Bus::OnDispatchStatusChanged(DBusConnection* connection,
1098 DBusDispatchStatus status) { 1098 DBusDispatchStatus /* status */) {
1099 DCHECK_EQ(connection, connection_); 1099 DCHECK_EQ(connection, connection_);
1100 AssertOnDBusThread(); 1100 AssertOnDBusThread();
1101 1101
1102 // We cannot call ProcessAllIncomingDataIfAny() here, as calling 1102 // We cannot call ProcessAllIncomingDataIfAny() here, as calling
1103 // dbus_connection_dispatch() inside DBusDispatchStatusFunction is 1103 // dbus_connection_dispatch() inside DBusDispatchStatusFunction is
1104 // prohibited by the D-Bus library. Hence, we post a task here instead. 1104 // prohibited by the D-Bus library. Hence, we post a task here instead.
1105 // See comments for dbus_connection_set_dispatch_status_function(). 1105 // See comments for dbus_connection_set_dispatch_status_function().
1106 GetDBusTaskRunner()->PostTask(FROM_HERE, 1106 GetDBusTaskRunner()->PostTask(FROM_HERE,
1107 base::Bind(&Bus::ProcessAllIncomingDataIfAny, 1107 base::Bind(&Bus::ProcessAllIncomingDataIfAny,
1108 this)); 1108 this));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 // static 1185 // static
1186 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, 1186 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection,
1187 DBusDispatchStatus status, 1187 DBusDispatchStatus status,
1188 void* data) { 1188 void* data) {
1189 Bus* self = static_cast<Bus*>(data); 1189 Bus* self = static_cast<Bus*>(data);
1190 self->OnDispatchStatusChanged(connection, status); 1190 self->OnDispatchStatusChanged(connection, status);
1191 } 1191 }
1192 1192
1193 // static 1193 // static
1194 DBusHandlerResult Bus::OnConnectionDisconnectedFilter( 1194 DBusHandlerResult Bus::OnConnectionDisconnectedFilter(
1195 DBusConnection* connection, 1195 DBusConnection* /* connection */,
1196 DBusMessage* message, 1196 DBusMessage* message,
1197 void* data) { 1197 void* /* data */) {
1198 if (dbus_message_is_signal(message, 1198 if (dbus_message_is_signal(message,
1199 DBUS_INTERFACE_LOCAL, 1199 DBUS_INTERFACE_LOCAL,
1200 kDisconnectedSignal)) { 1200 kDisconnectedSignal)) {
1201 // Abort when the connection is lost. 1201 // Abort when the connection is lost.
1202 LOG(FATAL) << "D-Bus connection was disconnected. Aborting."; 1202 LOG(FATAL) << "D-Bus connection was disconnected. Aborting.";
1203 } 1203 }
1204 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 1204 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1205 } 1205 }
1206 1206
1207 // static 1207 // static
1208 DBusHandlerResult Bus::OnServiceOwnerChangedFilter( 1208 DBusHandlerResult Bus::OnServiceOwnerChangedFilter(
1209 DBusConnection* connection, 1209 DBusConnection* /* connection */,
1210 DBusMessage* message, 1210 DBusMessage* message,
1211 void* data) { 1211 void* data) {
1212 if (dbus_message_is_signal(message, 1212 if (dbus_message_is_signal(message,
1213 DBUS_INTERFACE_DBUS, 1213 DBUS_INTERFACE_DBUS,
1214 kNameOwnerChangedSignal)) { 1214 kNameOwnerChangedSignal)) {
1215 Bus* self = static_cast<Bus*>(data); 1215 Bus* self = static_cast<Bus*>(data);
1216 self->OnServiceOwnerChanged(message); 1216 self->OnServiceOwnerChanged(message);
1217 } 1217 }
1218 // Always return unhandled to let others, e.g. ObjectProxies, handle the same 1218 // Always return unhandled to let others, e.g. ObjectProxies, handle the same
1219 // signal. 1219 // signal.
1220 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 1220 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1221 } 1221 }
1222 1222
1223 } // namespace dbus 1223 } // namespace dbus
OLDNEW
« crypto/secure_hash.cc ('K') | « crypto/secure_hash.cc ('k') | dbus/exported_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698