Skip to content

Commit

Permalink
Stop deleting ObjectProxy::OnPendingCallIsCompleteData manually
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
hashimoto authored and Commit bot committed Mar 30, 2015
1 parent b306439 commit 9aa653d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions dbus/object_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void ObjectProxy::StartAsyncMethodCall(int timeout_ms,
pending_call,
&ObjectProxy::OnPendingCallIsCompleteThunk,
data,
NULL);
&DeleteVoidPointer<OnPendingCallIsCompleteData>);
CHECK(success) << "Unable to allocate memory";
dbus_pending_call_unref(pending_call);

Expand Down Expand Up @@ -367,7 +367,6 @@ void ObjectProxy::OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call,
data->response_callback,
data->error_callback,
data->start_time);
delete data;
}

bool ObjectProxy::ConnectToNameOwnerChangedSignal() {
Expand Down
7 changes: 7 additions & 0 deletions dbus/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
void DeleteVoidPointer(void* memory) {
delete static_cast<T*>(memory);
}

} // namespace dbus

#endif // DBUS_UTIL_H_

0 comments on commit 9aa653d

Please sign in to comment.