diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-23 06:55:22 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-23 06:55:22 +0000 |
commit | ca72ff29277e39031e2b409e2a593b25d0066e8a (patch) | |
tree | bfadc8aeb37312310f8743ae4ff5e9a631c1c625 /dbus/message.cc | |
parent | f9cb2108d32497ca7688db99f144e0dbe73537da (diff) | |
download | chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.zip chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.tar.gz chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.tar.bz2 |
Change setters of dbus::Message to return false instead of aborting on errors
With this change, we can safely return error for invalid object path and service name.
It still crashes on invalid method name and interface name if we use MethodCall::MethodCall for setting those parameters.
BUG=128967
TEST=dbus_unittests
Review URL: https://chromiumcodereview.appspot.com/10409065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/message.cc')
-rw-r--r-- | dbus/message.cc | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/dbus/message.cc b/dbus/message.cc index 400c1bc..5b45d42 100644 --- a/dbus/message.cc +++ b/dbus/message.cc @@ -249,40 +249,28 @@ std::string Message::ToString() { return headers + "\n" + ToStringInternal("", &reader); } -void Message::SetDestination(const std::string& destination) { - const bool success = dbus_message_set_destination(raw_message_, - destination.c_str()); - CHECK(success) << "Unable to allocate memory"; +bool Message::SetDestination(const std::string& destination) { + return dbus_message_set_destination(raw_message_, destination.c_str()); } -void Message::SetPath(const ObjectPath& path) { - const bool success = dbus_message_set_path(raw_message_, - path.value().c_str()); - CHECK(success) << "Unable to allocate memory"; +bool Message::SetPath(const ObjectPath& path) { + return dbus_message_set_path(raw_message_, path.value().c_str()); } -void Message::SetInterface(const std::string& interface) { - const bool success = dbus_message_set_interface(raw_message_, - interface.c_str()); - CHECK(success) << "Unable to allocate memory"; +bool Message::SetInterface(const std::string& interface) { + return dbus_message_set_interface(raw_message_, interface.c_str()); } -void Message::SetMember(const std::string& member) { - const bool success = dbus_message_set_member(raw_message_, - member.c_str()); - CHECK(success) << "Unable to allocate memory"; +bool Message::SetMember(const std::string& member) { + return dbus_message_set_member(raw_message_, member.c_str()); } -void Message::SetErrorName(const std::string& error_name) { - const bool success = dbus_message_set_error_name(raw_message_, - error_name.c_str()); - CHECK(success) << "Unable to allocate memory"; +bool Message::SetErrorName(const std::string& error_name) { + return dbus_message_set_error_name(raw_message_, error_name.c_str()); } -void Message::SetSender(const std::string& sender) { - const bool success = dbus_message_set_sender(raw_message_, - sender.c_str()); - CHECK(success) << "Unable to allocate memory"; +bool Message::SetSender(const std::string& sender) { + return dbus_message_set_sender(raw_message_, sender.c_str()); } void Message::SetSerial(uint32 serial) { @@ -345,8 +333,8 @@ MethodCall::MethodCall(const std::string& interface_name, : Message() { Init(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)); - SetInterface(interface_name); - SetMember(method_name); + CHECK(SetInterface(interface_name)); + CHECK(SetMember(method_name)); } MethodCall::MethodCall() : Message() { @@ -368,8 +356,8 @@ Signal::Signal(const std::string& interface_name, : Message() { Init(dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL)); - SetInterface(interface_name); - SetMember(method_name); + CHECK(SetInterface(interface_name)); + CHECK(SetMember(method_name)); } Signal::Signal() : Message() { |