From 9aa653d4ac52f2c89bfa5164a5eddd8164bb9987 Mon Sep 17 00:00:00 2001 From: hashimoto Date: Sun, 29 Mar 2015 23:52:21 -0700 Subject: Stop deleting ObjectProxy::OnPendingCallIsCompleteData manually Instead, let libdbus handle it. This also makes it easier to implement method call cancellation. BUG=471175 Review URL: https://codereview.chromium.org/1032263002 Cr-Commit-Position: refs/heads/master@{#322746} --- dbus/object_proxy.cc | 3 +-- dbus/util.h | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc index 7347db0..974b24c 100644 --- a/dbus/object_proxy.cc +++ b/dbus/object_proxy.cc @@ -275,7 +275,7 @@ void ObjectProxy::StartAsyncMethodCall(int timeout_ms, pending_call, &ObjectProxy::OnPendingCallIsCompleteThunk, data, - NULL); + &DeleteVoidPointer); CHECK(success) << "Unable to allocate memory"; dbus_pending_call_unref(pending_call); @@ -367,7 +367,6 @@ void ObjectProxy::OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call, data->response_callback, data->error_callback, data->start_time); - delete data; } bool ObjectProxy::ConnectToNameOwnerChangedSignal() { diff --git a/dbus/util.h b/dbus/util.h index b983b6f..b05834d 100644 --- a/dbus/util.h +++ b/dbus/util.h @@ -23,6 +23,13 @@ CHROME_DBUS_EXPORT std::string GetAbsoluteMemberName( const std::string& interface_name, const std::string& member_name); +// Similar to base::DeletePointer, but takes void* as an argument. +// Used as DBusFreeFunction. +template +void DeleteVoidPointer(void* memory) { + delete static_cast(memory); +} + } // namespace dbus #endif // DBUS_UTIL_H_ -- cgit v1.1