chromeos: Avoid org.neard.Manager D-Bus log spam.
Make NfcManagerClientImpl defer making its initial call to get neard's properties until D-Bus has notified Chrome that neard is available. BUG=636554 TBR=stevenjb@chromium.org Review-Url: https://codereview.chromium.org/2238703002 Cr-Commit-Position: refs/heads/master@{#413743}
This commit is contained in:
@ -202,6 +202,12 @@ class NfcClientTest : public testing::Test {
|
||||
dbus::ObjectPath(kTestTagPath1)))
|
||||
.WillRepeatedly(Return(mock_tag1_proxy_.get()));
|
||||
|
||||
// Handle |manager_client_|'s request to register a callback
|
||||
// for |mock_manager_proxy_|'s D-Bus service becoming available.
|
||||
EXPECT_CALL(*mock_manager_proxy_.get(), WaitForServiceToBeAvailable(_))
|
||||
.WillRepeatedly(
|
||||
Invoke(this, &NfcClientTest::OnWaitForServiceToBeAvailable));
|
||||
|
||||
// ShutdownAndBlock will be called in TearDown.
|
||||
EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return());
|
||||
|
||||
@ -370,6 +376,13 @@ class NfcClientTest : public testing::Test {
|
||||
dbus::ObjectProxy::SignalCallback manager_adapter_removed_signal_callback_;
|
||||
|
||||
private:
|
||||
// Used to inform |manager_client_| that |mock_manager_proxy_| is ready.
|
||||
void OnWaitForServiceToBeAvailable(
|
||||
dbus::ObjectProxy::WaitForServiceToBeAvailableCallback callback) {
|
||||
message_loop_.task_runner()->PostTask(FROM_HERE,
|
||||
base::Bind(callback, true));
|
||||
}
|
||||
|
||||
// Used to implement the mock proxy.
|
||||
void OnConnectToSignal(
|
||||
const std::string& interface_name,
|
||||
|
@ -70,7 +70,6 @@ class NfcManagerClientImpl : public NfcManagerClient {
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
base::Bind(&NfcManagerClientImpl::AdapterAddedConnected,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
|
||||
object_proxy_->ConnectToSignal(
|
||||
nfc_manager::kNfcManagerInterface,
|
||||
nfc_manager::kAdapterRemovedSignal,
|
||||
@ -84,12 +83,23 @@ class NfcManagerClientImpl : public NfcManagerClient {
|
||||
object_proxy_,
|
||||
base::Bind(&NfcManagerClientImpl::OnPropertyChanged,
|
||||
weak_ptr_factory_.GetWeakPtr())));
|
||||
|
||||
properties_->ConnectSignals();
|
||||
properties_->GetAll();
|
||||
|
||||
object_proxy_->WaitForServiceToBeAvailable(
|
||||
base::Bind(&NfcManagerClientImpl::OnServiceInitiallyAvailable,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
private:
|
||||
// Called by |object_proxy_| when the D-Bus service initially becomes
|
||||
// available.
|
||||
void OnServiceInitiallyAvailable(bool service_is_available) {
|
||||
if (service_is_available)
|
||||
properties_->GetAll();
|
||||
else
|
||||
LOG(ERROR) << "Failed to wait for D-Bus service to become available";
|
||||
}
|
||||
|
||||
// NFC manager signal handlers.
|
||||
void OnPropertyChanged(const std::string& property_name) {
|
||||
VLOG(1) << "NFC Manager property changed: " << property_name;
|
||||
@ -97,7 +107,7 @@ class NfcManagerClientImpl : public NfcManagerClient {
|
||||
ManagerPropertyChanged(property_name));
|
||||
}
|
||||
|
||||
// Called by dbus:: when an "AdapterAdded" signal is received..
|
||||
// Called by dbus:: when an "AdapterAdded" signal is received.
|
||||
void AdapterAddedReceived(dbus::Signal* signal) {
|
||||
DCHECK(signal);
|
||||
dbus::MessageReader reader(signal);
|
||||
|
@ -56,6 +56,8 @@ class MockObjectProxy : public ObjectProxy {
|
||||
const std::string& signal_name,
|
||||
SignalCallback signal_callback,
|
||||
OnConnectedCallback on_connected_callback));
|
||||
MOCK_METHOD1(WaitForServiceToBeAvailable,
|
||||
void(WaitForServiceToBeAvailableCallback callback));
|
||||
MOCK_METHOD0(Detach, void());
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user