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

Unified Diff: dbus/object_proxy.cc

Issue 1074963003: Clean up potentially leaky use of base::DeletePointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed another probleb Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/object_proxy.h ('k') | device/core/device_monitor_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/object_proxy.cc
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc
index 441dc757bd707add204cd4b07f53a74edca27b33..3d410a3ba0e1b044d5f693096263911e8be4b575 100644
--- a/dbus/object_proxy.cc
+++ b/dbus/object_proxy.cc
@@ -329,7 +329,7 @@ void ObjectProxy::RunResponseCallback(ResponseCallback response_callback,
bus_->GetDBusTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&base::DeletePointer<ErrorResponse>,
- error_response.release()));
+ base::Passed(&error_response)));
} else {
// This will take |response_message| and release (unref) it.
scoped_ptr<Response> response(Response::FromRawMessage(response_message));
@@ -355,7 +355,7 @@ void ObjectProxy::RunResponseCallback(ResponseCallback response_callback,
// thread, not from the current thread here, which is likely UI thread.
bus_->GetDBusTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&base::DeletePointer<Response>, response.release()));
+ base::Bind(&base::DeletePointer<Response>, base::Passed(&response)));
method_call_successful = true;
// Record time spent for the method call. Don't include failures.
@@ -506,19 +506,17 @@ DBusHandlerResult ObjectProxy::HandleMessage(
// Post a task to run the method in the origin thread.
// Transfer the ownership of |signal| to RunMethod().
// |released_signal| will be deleted in RunMethod().
- Signal* released_signal = signal.release();
bus_->GetOriginTaskRunner()->PostTask(FROM_HERE,
base::Bind(&ObjectProxy::RunMethod,
this,
start_time,
iter->second,
- released_signal));
+ base::Passed(&signal)));
} else {
const base::TimeTicks start_time = base::TimeTicks::Now();
// If the D-Bus thread is not used, just call the callback on the
// current thread. Transfer the ownership of |signal| to RunMethod().
- Signal* released_signal = signal.release();
- RunMethod(start_time, iter->second, released_signal);
+ RunMethod(start_time, iter->second, signal.Pass());
}
// We don't return DBUS_HANDLER_RESULT_HANDLED for signals because other
@@ -528,18 +526,18 @@ DBusHandlerResult ObjectProxy::HandleMessage(
void ObjectProxy::RunMethod(base::TimeTicks start_time,
std::vector<SignalCallback> signal_callbacks,
- Signal* signal) {
+ scoped_ptr<Signal> signal) {
bus_->AssertOnOriginThread();
for (std::vector<SignalCallback>::iterator iter = signal_callbacks.begin();
iter != signal_callbacks.end(); ++iter)
- iter->Run(signal);
+ iter->Run(signal.get());
// Delete the message on the D-Bus thread. See comments in
// RunResponseCallback().
bus_->GetDBusTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&base::DeletePointer<Signal>, signal));
+ base::Bind(&base::DeletePointer<Signal>, base::Passed(&signal)));
// Record time spent for handling the signal.
UMA_HISTOGRAM_TIMES("DBus.SignalHandleTime",
« no previous file with comments | « dbus/object_proxy.h ('k') | device/core/device_monitor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698