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

Side by Side Diff: dbus/object_proxy.cc

Issue 1032263002: Stop deleting ObjectProxy::OnPendingCallIsCompleteData manually (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | dbus/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bus.h" 5 #include "dbus/bus.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // The data will be deleted in OnPendingCallIsCompleteThunk(). 268 // The data will be deleted in OnPendingCallIsCompleteThunk().
269 OnPendingCallIsCompleteData* data = 269 OnPendingCallIsCompleteData* data =
270 new OnPendingCallIsCompleteData(this, response_callback, error_callback, 270 new OnPendingCallIsCompleteData(this, response_callback, error_callback,
271 start_time); 271 start_time);
272 272
273 // This returns false only when unable to allocate memory. 273 // This returns false only when unable to allocate memory.
274 const bool success = dbus_pending_call_set_notify( 274 const bool success = dbus_pending_call_set_notify(
275 pending_call, 275 pending_call,
276 &ObjectProxy::OnPendingCallIsCompleteThunk, 276 &ObjectProxy::OnPendingCallIsCompleteThunk,
277 data, 277 data,
278 NULL); 278 &DeleteVoidPointer<OnPendingCallIsCompleteData>);
279 CHECK(success) << "Unable to allocate memory"; 279 CHECK(success) << "Unable to allocate memory";
280 dbus_pending_call_unref(pending_call); 280 dbus_pending_call_unref(pending_call);
281 281
282 // It's now safe to unref the request message. 282 // It's now safe to unref the request message.
283 dbus_message_unref(request_message); 283 dbus_message_unref(request_message);
284 } 284 }
285 285
286 void ObjectProxy::OnPendingCallIsComplete(DBusPendingCall* pending_call, 286 void ObjectProxy::OnPendingCallIsComplete(DBusPendingCall* pending_call,
287 ResponseCallback response_callback, 287 ResponseCallback response_callback,
288 ErrorCallback error_callback, 288 ErrorCallback error_callback,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 void ObjectProxy::OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call, 361 void ObjectProxy::OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call,
362 void* user_data) { 362 void* user_data) {
363 OnPendingCallIsCompleteData* data = 363 OnPendingCallIsCompleteData* data =
364 reinterpret_cast<OnPendingCallIsCompleteData*>(user_data); 364 reinterpret_cast<OnPendingCallIsCompleteData*>(user_data);
365 ObjectProxy* self = data->object_proxy; 365 ObjectProxy* self = data->object_proxy;
366 self->OnPendingCallIsComplete(pending_call, 366 self->OnPendingCallIsComplete(pending_call,
367 data->response_callback, 367 data->response_callback,
368 data->error_callback, 368 data->error_callback,
369 data->start_time); 369 data->start_time);
370 delete data;
371 } 370 }
372 371
373 bool ObjectProxy::ConnectToNameOwnerChangedSignal() { 372 bool ObjectProxy::ConnectToNameOwnerChangedSignal() {
374 bus_->AssertOnDBusThread(); 373 bus_->AssertOnDBusThread();
375 374
376 if (!bus_->Connect() || !bus_->SetUpAsyncOperations()) 375 if (!bus_->Connect() || !bus_->SetUpAsyncOperations())
377 return false; 376 return false;
378 377
379 bus_->AddFilterFunction(&ObjectProxy::HandleMessageThunk, this); 378 bus_->AddFilterFunction(&ObjectProxy::HandleMessageThunk, this);
380 379
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 bool service_is_available) { 690 bool service_is_available) {
692 bus_->AssertOnOriginThread(); 691 bus_->AssertOnOriginThread();
693 692
694 std::vector<WaitForServiceToBeAvailableCallback> callbacks; 693 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
695 callbacks.swap(wait_for_service_to_be_available_callbacks_); 694 callbacks.swap(wait_for_service_to_be_available_callbacks_);
696 for (size_t i = 0; i < callbacks.size(); ++i) 695 for (size_t i = 0; i < callbacks.size(); ++i)
697 callbacks[i].Run(service_is_available); 696 callbacks[i].Run(service_is_available);
698 } 697 }
699 698
700 } // namespace dbus 699 } // namespace dbus
OLDNEW
« no previous file with comments | « no previous file | dbus/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698