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

Side by Side Diff: dbus/object_proxy.cc

Issue 11358111: Make SignalSenderVerificationTest more robust (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: update header commnets Created 8 years, 1 month 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
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.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 void ObjectProxy::OnConnected(OnConnectedCallback on_connected_callback, 402 void ObjectProxy::OnConnected(OnConnectedCallback on_connected_callback,
403 const std::string& interface_name, 403 const std::string& interface_name,
404 const std::string& signal_name, 404 const std::string& signal_name,
405 bool success) { 405 bool success) {
406 bus_->AssertOnOriginThread(); 406 bus_->AssertOnOriginThread();
407 407
408 on_connected_callback.Run(interface_name, signal_name, success); 408 on_connected_callback.Run(interface_name, signal_name, success);
409 } 409 }
410 410
411 void ObjectProxy::SetNameOwnerChangedCallback(SignalCallback callback) {
412 bus_->AssertOnOriginThread();
413
414 name_owner_changed_callback_ = callback;
415 }
416
411 DBusHandlerResult ObjectProxy::HandleMessage( 417 DBusHandlerResult ObjectProxy::HandleMessage(
412 DBusConnection* connection, 418 DBusConnection* connection,
413 DBusMessage* raw_message) { 419 DBusMessage* raw_message) {
414 bus_->AssertOnDBusThread(); 420 bus_->AssertOnDBusThread();
415 421
416 if (dbus_message_get_type(raw_message) != DBUS_MESSAGE_TYPE_SIGNAL) 422 if (dbus_message_get_type(raw_message) != DBUS_MESSAGE_TYPE_SIGNAL)
417 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 423 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
418 424
419 // raw_message will be unrefed on exit of the function. Increment the 425 // raw_message will be unrefed on exit of the function. Increment the
420 // reference so we can use it in Signal. 426 // reference so we can use it in Signal.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 if (signal->GetMember() == "NameOwnerChanged" && 633 if (signal->GetMember() == "NameOwnerChanged" &&
628 signal->GetInterface() == "org.freedesktop.DBus" && 634 signal->GetInterface() == "org.freedesktop.DBus" &&
629 signal->GetSender() == "org.freedesktop.DBus") { 635 signal->GetSender() == "org.freedesktop.DBus") {
630 MessageReader reader(signal); 636 MessageReader reader(signal);
631 std::string name, old_owner, new_owner; 637 std::string name, old_owner, new_owner;
632 if (reader.PopString(&name) && 638 if (reader.PopString(&name) &&
633 reader.PopString(&old_owner) && 639 reader.PopString(&old_owner) &&
634 reader.PopString(&new_owner) && 640 reader.PopString(&new_owner) &&
635 name == service_name_) { 641 name == service_name_) {
636 service_name_owner_ = new_owner; 642 service_name_owner_ = new_owner;
643 name_owner_changed_callback_.Run(signal);
satorux1 2012/11/12 07:56:43 This will crash if name_owner_changed_callback_ is
Haruki Sato 2012/11/13 06:23:28 Done. Thanks.
637 return DBUS_HANDLER_RESULT_HANDLED; 644 return DBUS_HANDLER_RESULT_HANDLED;
638 } 645 }
639 } 646 }
640 647
641 // Untrusted or uninteresting signal 648 // Untrusted or uninteresting signal
642 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 649 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
643 } 650 }
644 651
645 } // namespace dbus 652 } // namespace dbus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698