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

Side by Side Diff: dbus/object_proxy.cc

Issue 510863002: dbus::ObjectManager: Add a match rule for properties before GetManagedObjects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased; updated BUILD.gn; fixed crash from latest RunLoop changes Created 6 years, 3 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 | « dbus/object_manager_unittest.cc ('k') | dbus/test_service.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"
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "dbus/dbus_statistics.h" 16 #include "dbus/dbus_statistics.h"
17 #include "dbus/message.h" 17 #include "dbus/message.h"
18 #include "dbus/object_path.h" 18 #include "dbus/object_path.h"
19 #include "dbus/object_proxy.h" 19 #include "dbus/object_proxy.h"
20 #include "dbus/scoped_dbus_error.h" 20 #include "dbus/scoped_dbus_error.h"
21 #include "dbus/util.h"
21 22
22 namespace dbus { 23 namespace dbus {
23 24
24 namespace { 25 namespace {
25 26
26 const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown"; 27 const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown";
27 const char kErrorObjectUnknown[] = "org.freedesktop.DBus.Error.UnknownObject"; 28 const char kErrorObjectUnknown[] = "org.freedesktop.DBus.Error.UnknownObject";
28 29
29 // Used for success ratio histograms. 1 for success, 0 for failure. 30 // Used for success ratio histograms. 1 for success, 0 for failure.
30 const int kSuccessRatioHistogramMaxValue = 2; 31 const int kSuccessRatioHistogramMaxValue = 2;
31 32
32 // The path of D-Bus Object sending NameOwnerChanged signal. 33 // The path of D-Bus Object sending NameOwnerChanged signal.
33 const char kDBusSystemObjectPath[] = "/org/freedesktop/DBus"; 34 const char kDBusSystemObjectPath[] = "/org/freedesktop/DBus";
34 35
35 // The D-Bus Object interface. 36 // The D-Bus Object interface.
36 const char kDBusSystemObjectInterface[] = "org.freedesktop.DBus"; 37 const char kDBusSystemObjectInterface[] = "org.freedesktop.DBus";
37 38
38 // The D-Bus Object address. 39 // The D-Bus Object address.
39 const char kDBusSystemObjectAddress[] = "org.freedesktop.DBus"; 40 const char kDBusSystemObjectAddress[] = "org.freedesktop.DBus";
40 41
41 // The NameOwnerChanged member in |kDBusSystemObjectInterface|. 42 // The NameOwnerChanged member in |kDBusSystemObjectInterface|.
42 const char kNameOwnerChangedMember[] = "NameOwnerChanged"; 43 const char kNameOwnerChangedMember[] = "NameOwnerChanged";
43 44
44 // Gets the absolute signal name by concatenating the interface name and
45 // the signal name. Used for building keys for method_table_ in
46 // ObjectProxy.
47 std::string GetAbsoluteSignalName(
48 const std::string& interface_name,
49 const std::string& signal_name) {
50 return interface_name + "." + signal_name;
51 }
52
53 // An empty function used for ObjectProxy::EmptyResponseCallback(). 45 // An empty function used for ObjectProxy::EmptyResponseCallback().
54 void EmptyResponseCallbackBody(Response* /*response*/) { 46 void EmptyResponseCallbackBody(Response* /*response*/) {
55 } 47 }
56 48
57 } // namespace 49 } // namespace
58 50
59 ObjectProxy::ObjectProxy(Bus* bus, 51 ObjectProxy::ObjectProxy(Bus* bus,
60 const std::string& service_name, 52 const std::string& service_name,
61 const ObjectPath& object_path, 53 const ObjectPath& object_path,
62 int options) 54 int options)
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 406
415 bool ObjectProxy::ConnectToSignalInternal(const std::string& interface_name, 407 bool ObjectProxy::ConnectToSignalInternal(const std::string& interface_name,
416 const std::string& signal_name, 408 const std::string& signal_name,
417 SignalCallback signal_callback) { 409 SignalCallback signal_callback) {
418 bus_->AssertOnDBusThread(); 410 bus_->AssertOnDBusThread();
419 411
420 if (!ConnectToNameOwnerChangedSignal()) 412 if (!ConnectToNameOwnerChangedSignal())
421 return false; 413 return false;
422 414
423 const std::string absolute_signal_name = 415 const std::string absolute_signal_name =
424 GetAbsoluteSignalName(interface_name, signal_name); 416 GetAbsoluteMemberName(interface_name, signal_name);
425 417
426 // Add a match rule so the signal goes through HandleMessage(). 418 // Add a match rule so the signal goes through HandleMessage().
427 const std::string match_rule = 419 const std::string match_rule =
428 base::StringPrintf("type='signal', interface='%s', path='%s'", 420 base::StringPrintf("type='signal', interface='%s', path='%s'",
429 interface_name.c_str(), 421 interface_name.c_str(),
430 object_path_.value().c_str()); 422 object_path_.value().c_str());
431 return AddMatchRuleWithCallback(match_rule, 423 return AddMatchRuleWithCallback(match_rule,
432 absolute_signal_name, 424 absolute_signal_name,
433 signal_callback); 425 signal_callback);
434 } 426 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 473 }
482 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 474 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
483 } 475 }
484 476
485 const std::string interface = signal->GetInterface(); 477 const std::string interface = signal->GetInterface();
486 const std::string member = signal->GetMember(); 478 const std::string member = signal->GetMember();
487 479
488 statistics::AddReceivedSignal(service_name_, interface, member); 480 statistics::AddReceivedSignal(service_name_, interface, member);
489 481
490 // Check if we know about the signal. 482 // Check if we know about the signal.
491 const std::string absolute_signal_name = GetAbsoluteSignalName( 483 const std::string absolute_signal_name = GetAbsoluteMemberName(
492 interface, member); 484 interface, member);
493 MethodTable::const_iterator iter = method_table_.find(absolute_signal_name); 485 MethodTable::const_iterator iter = method_table_.find(absolute_signal_name);
494 if (iter == method_table_.end()) { 486 if (iter == method_table_.end()) {
495 // Don't know about the signal. 487 // Don't know about the signal.
496 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 488 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
497 } 489 }
498 VLOG(1) << "Signal received: " << signal->ToString(); 490 VLOG(1) << "Signal received: " << signal->ToString();
499 491
500 std::string sender = signal->GetSender(); 492 std::string sender = signal->GetSender();
501 if (service_name_owner_ != sender) { 493 if (service_name_owner_ != sender) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 bool service_is_available) { 695 bool service_is_available) {
704 bus_->AssertOnOriginThread(); 696 bus_->AssertOnOriginThread();
705 697
706 std::vector<WaitForServiceToBeAvailableCallback> callbacks; 698 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
707 callbacks.swap(wait_for_service_to_be_available_callbacks_); 699 callbacks.swap(wait_for_service_to_be_available_callbacks_);
708 for (size_t i = 0; i < callbacks.size(); ++i) 700 for (size_t i = 0; i < callbacks.size(); ++i)
709 callbacks[i].Run(service_is_available); 701 callbacks[i].Run(service_is_available);
710 } 702 }
711 703
712 } // namespace dbus 704 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/object_manager_unittest.cc ('k') | dbus/test_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698