| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/object_manager.h" | 5 #include "dbus/object_manager.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/location.h" | 10 #include "base/location.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 242 } |
| 243 | 243 |
| 244 // static | 244 // static |
| 245 DBusHandlerResult ObjectManager::HandleMessageThunk(DBusConnection* connection, | 245 DBusHandlerResult ObjectManager::HandleMessageThunk(DBusConnection* connection, |
| 246 DBusMessage* raw_message, | 246 DBusMessage* raw_message, |
| 247 void* user_data) { | 247 void* user_data) { |
| 248 ObjectManager* self = reinterpret_cast<ObjectManager*>(user_data); | 248 ObjectManager* self = reinterpret_cast<ObjectManager*>(user_data); |
| 249 return self->HandleMessage(connection, raw_message); | 249 return self->HandleMessage(connection, raw_message); |
| 250 } | 250 } |
| 251 | 251 |
| 252 DBusHandlerResult ObjectManager::HandleMessage(DBusConnection* connection, | 252 DBusHandlerResult ObjectManager::HandleMessage(DBusConnection*, |
| 253 DBusMessage* raw_message) { | 253 DBusMessage* raw_message) { |
| 254 DCHECK(bus_); | 254 DCHECK(bus_); |
| 255 bus_->AssertOnDBusThread(); | 255 bus_->AssertOnDBusThread(); |
| 256 | 256 |
| 257 // Handle the message only if it is a signal. | 257 // Handle the message only if it is a signal. |
| 258 // Note that the match rule in SetupMatchRuleAndFilter() is configured to | 258 // Note that the match rule in SetupMatchRuleAndFilter() is configured to |
| 259 // only accept signals, but we check here just in case. | 259 // only accept signals, but we check here just in case. |
| 260 if (dbus_message_get_type(raw_message) != DBUS_MESSAGE_TYPE_SIGNAL) | 260 if (dbus_message_get_type(raw_message) != DBUS_MESSAGE_TYPE_SIGNAL) |
| 261 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 261 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 262 | 262 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 if (!reader.PopObjectPath(&object_path)) { | 378 if (!reader.PopObjectPath(&object_path)) { |
| 379 LOG(WARNING) << service_name_ << " " << object_path_.value() | 379 LOG(WARNING) << service_name_ << " " << object_path_.value() |
| 380 << ": InterfacesAdded signal has incorrect parameters: " | 380 << ": InterfacesAdded signal has incorrect parameters: " |
| 381 << signal->ToString(); | 381 << signal->ToString(); |
| 382 return; | 382 return; |
| 383 } | 383 } |
| 384 | 384 |
| 385 UpdateObject(object_path, &reader); | 385 UpdateObject(object_path, &reader); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void ObjectManager::InterfacesAddedConnected(const std::string& interface_name, | 388 void ObjectManager::InterfacesAddedConnected( |
| 389 const std::string& signal_name, | 389 const std::string& /*interface_name*/, |
| 390 bool success) { | 390 const std::string& /*signal_name*/, |
| 391 bool success) { |
| 391 LOG_IF(WARNING, !success) << service_name_ << " " << object_path_.value() | 392 LOG_IF(WARNING, !success) << service_name_ << " " << object_path_.value() |
| 392 << ": Failed to connect to InterfacesAdded signal."; | 393 << ": Failed to connect to InterfacesAdded signal."; |
| 393 } | 394 } |
| 394 | 395 |
| 395 void ObjectManager::InterfacesRemovedReceived(Signal* signal) { | 396 void ObjectManager::InterfacesRemovedReceived(Signal* signal) { |
| 396 DCHECK(signal); | 397 DCHECK(signal); |
| 397 MessageReader reader(signal); | 398 MessageReader reader(signal); |
| 398 ObjectPath object_path; | 399 ObjectPath object_path; |
| 399 std::vector<std::string> interface_names; | 400 std::vector<std::string> interface_names; |
| 400 if (!reader.PopObjectPath(&object_path) || | 401 if (!reader.PopObjectPath(&object_path) || |
| 401 !reader.PopArrayOfStrings(&interface_names)) { | 402 !reader.PopArrayOfStrings(&interface_names)) { |
| 402 LOG(WARNING) << service_name_ << " " << object_path_.value() | 403 LOG(WARNING) << service_name_ << " " << object_path_.value() |
| 403 << ": InterfacesRemoved signal has incorrect parameters: " | 404 << ": InterfacesRemoved signal has incorrect parameters: " |
| 404 << signal->ToString(); | 405 << signal->ToString(); |
| 405 return; | 406 return; |
| 406 } | 407 } |
| 407 | 408 |
| 408 for (size_t i = 0; i < interface_names.size(); ++i) | 409 for (size_t i = 0; i < interface_names.size(); ++i) |
| 409 RemoveInterface(object_path, interface_names[i]); | 410 RemoveInterface(object_path, interface_names[i]); |
| 410 } | 411 } |
| 411 | 412 |
| 412 void ObjectManager::InterfacesRemovedConnected( | 413 void ObjectManager::InterfacesRemovedConnected( |
| 413 const std::string& interface_name, | 414 const std::string& /*interface_name*/, |
| 414 const std::string& signal_name, | 415 const std::string& /*signal_name*/, |
| 415 bool success) { | 416 bool success) { |
| 416 LOG_IF(WARNING, !success) << service_name_ << " " << object_path_.value() | 417 LOG_IF(WARNING, !success) << service_name_ << " " << object_path_.value() |
| 417 << ": Failed to connect to " | 418 << ": Failed to connect to " |
| 418 << "InterfacesRemoved signal."; | 419 << "InterfacesRemoved signal."; |
| 419 } | 420 } |
| 420 | 421 |
| 421 void ObjectManager::UpdateObject(const ObjectPath& object_path, | 422 void ObjectManager::UpdateObject(const ObjectPath& object_path, |
| 422 MessageReader* reader) { | 423 MessageReader* reader) { |
| 423 DCHECK(reader); | 424 DCHECK(reader); |
| 424 MessageReader array_reader(NULL); | 425 MessageReader array_reader(NULL); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 RemoveInterface(object_path, *iiter); | 527 RemoveInterface(object_path, *iiter); |
| 527 } | 528 } |
| 528 | 529 |
| 529 } | 530 } |
| 530 | 531 |
| 531 if (!new_owner.empty()) | 532 if (!new_owner.empty()) |
| 532 GetManagedObjects(); | 533 GetManagedObjects(); |
| 533 } | 534 } |
| 534 | 535 |
| 535 } // namespace dbus | 536 } // namespace dbus |
| OLD | NEW |