11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file. 41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chromeos/dbus/nfc_adapter_client.h" 61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include <map> 81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include <utility> 91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/bind.h" 111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/observer_list.h" 131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/strings/stringprintf.h" 141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chromeos/dbus/nfc_manager_client.h" 151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "dbus/bus.h" 161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "dbus/message.h" 171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "third_party/cros_system_api/dbus/service_constants.h" 181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace chromeos { 201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)NfcAdapterClient::Properties::Properties( 221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::ObjectProxy* object_proxy, 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const PropertyChangedCallback& callback) 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) : NfcPropertySet(object_proxy, 251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) nfc_adapter::kNfcAdapterInterface, 261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) callback) { 271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RegisterProperty(nfc_adapter::kModeProperty, &mode); 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RegisterProperty(nfc_adapter::kPoweredProperty, &powered); 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RegisterProperty(nfc_adapter::kPollingProperty, &polling); 301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RegisterProperty(nfc_adapter::kProtocolsProperty, &protocols); 311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RegisterProperty(nfc_adapter::kTagsProperty, &tags); 321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RegisterProperty(nfc_adapter::kDevicesProperty, &devices); 331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)NfcAdapterClient::Properties::~Properties() { 361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// The NfcAdapterClient implementation used in production. 391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class NfcAdapterClientImpl 401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) : public NfcAdapterClient, 411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public NfcManagerClient::Observer, 421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public nfc_client_helpers::DBusObjectMap::Delegate { 431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public: 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) explicit NfcAdapterClientImpl(NfcManagerClient* manager_client) 450f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) : bus_(NULL), 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) manager_client_(manager_client), 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) weak_ptr_factory_(this) { 481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DCHECK(manager_client); 491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual ~NfcAdapterClientImpl() { 521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) manager_client_->RemoveObserver(this); 531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // NfcAdapterClient override. 561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void AddObserver(NfcAdapterClient::Observer* observer) OVERRIDE { 571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DCHECK(observer); 581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) observers_.AddObserver(observer); 591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // NfcAdapterClient override. 621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void RemoveObserver(NfcAdapterClient::Observer* observer) OVERRIDE { 631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DCHECK(observer); 641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) observers_.RemoveObserver(observer); 651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // NfcAdapterClient override. 68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual std::vector<dbus::ObjectPath> GetAdapters() OVERRIDE { 69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return object_map_->GetObjectPaths(); 70a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // NfcAdapterClient override. 731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual Properties* GetProperties(const dbus::ObjectPath& object_path) 741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) OVERRIDE { 751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return static_cast<Properties*>( 761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) object_map_->GetObjectProperties(object_path)); 771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // NfcAdapterClient override. 801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void StartPollLoop( 811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const dbus::ObjectPath& object_path, 821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const std::string& mode, 831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const base::Closure& callback, 841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const nfc_client_helpers::ErrorCallback& error_callback) OVERRIDE { 851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::ObjectProxy* object_proxy = object_map_->GetObjectProxy(object_path); 861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!object_proxy) { 871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) std::string error_message = 881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::StringPrintf("NFC adapter with object path \"%s\" does not " 891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) "exist.", object_path.value().c_str()); 901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) LOG(ERROR) << error_message; 911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) error_callback.Run(nfc_client_helpers::kUnknownObjectError, 921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) error_message); 931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return; 941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::MethodCall method_call(nfc_adapter::kNfcAdapterInterface, 961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) nfc_adapter::kStartPollLoop); 971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::MessageWriter writer(&method_call); 981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) writer.AppendString(mode); 991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) object_proxy->CallMethodWithErrorCallback( 1001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) &method_call, 1011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 1021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&nfc_client_helpers::OnSuccess, callback), 1031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&nfc_client_helpers::OnError, error_callback)); 1041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // NfcAdapterClient override. 1071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void StopPollLoop( 1081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const dbus::ObjectPath& object_path, 1091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const base::Closure& callback, 1101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const nfc_client_helpers::ErrorCallback& error_callback) OVERRIDE { 1111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::ObjectProxy* object_proxy = object_map_->GetObjectProxy(object_path); 1121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!object_proxy) { 1131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) std::string error_message = 1141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::StringPrintf("NFC adapter with object path \"%s\" does not " 1151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) "exist.", object_path.value().c_str()); 1161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) LOG(ERROR) << error_message; 1171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) error_callback.Run(nfc_client_helpers::kUnknownObjectError, 1181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) error_message); 1191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return; 1201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::MethodCall method_call(nfc_adapter::kNfcAdapterInterface, 1221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) nfc_adapter::kStopPollLoop); 1231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) object_proxy->CallMethodWithErrorCallback( 1241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) &method_call, 1251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 1261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&nfc_client_helpers::OnSuccess, callback), 1271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&nfc_client_helpers::OnError, error_callback)); 1281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) protected: 1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // DBusClient override. 1321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void Init(dbus::Bus* bus) OVERRIDE { 1331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) VLOG(1) << "Creating NfcAdapterClientImpl"; 1341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DCHECK(bus); 1351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) bus_ = bus; 1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) object_map_.reset(new nfc_client_helpers::DBusObjectMap( 1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) nfc_adapter::kNfcAdapterServiceName, this, bus)); 1381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DCHECK(manager_client_); 1391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) manager_client_->AddObserver(this); 1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private: 1431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // NfcManagerClient::Observer override. 1440f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual void ManagerPropertyChanged( 1450f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) const std::string& property_name) OVERRIDE { 1460f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // Update the adapter proxies. 1470f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) DCHECK(manager_client_); 1481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) NfcManagerClient::Properties* manager_properties = 1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) manager_client_->GetProperties(); 1500f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 1510f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // Ignore changes to properties other than "Adapters". 1520f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) if (property_name != manager_properties->adapters.name()) 1530f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) return; 1540f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 1550f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // Update the known adapters. 156f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) VLOG(1) << "NFC adapters changed."; 1570f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) const std::vector<dbus::ObjectPath>& received_adapters = 1580f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) manager_properties->adapters.value(); 1590f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) object_map_->UpdateObjects(received_adapters); 1601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // nfc_client_helpers::DBusObjectMap::Delegate override. 1631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual NfcPropertySet* CreateProperties( 1641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::ObjectProxy* object_proxy) OVERRIDE { 1651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return new Properties( 1661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) object_proxy, 1671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&NfcAdapterClientImpl::OnPropertyChanged, 1681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) weak_ptr_factory_.GetWeakPtr(), 1691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) object_proxy->object_path())); 1701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1720f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // nfc_client_helpers::DBusObjectMap::Delegate override. 1730f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual void ObjectAdded(const dbus::ObjectPath& object_path) OVERRIDE { 1740f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) FOR_EACH_OBSERVER(NfcAdapterClient::Observer, observers_, 1750f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) AdapterAdded(object_path)); 1760f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) } 1770f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 178a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // nfc_client_helpers::DBusObjectMap::Delegate override. 1790f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual void ObjectRemoved(const dbus::ObjectPath& object_path) OVERRIDE { 1800f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) FOR_EACH_OBSERVER(NfcAdapterClient::Observer, observers_, 1810f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) AdapterRemoved(object_path)); 1820f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) } 1830f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 1841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Called by NfcPropertySet when a property value is changed, either by 1851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // result of a signal or response to a GetAll() or Get() call. 1861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void OnPropertyChanged(const dbus::ObjectPath& object_path, 1871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const std::string& property_name) { 1881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) VLOG(1) << "Adapter property changed; Path: " << object_path.value() 1891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) << " Property: " << property_name; 1901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) FOR_EACH_OBSERVER(NfcAdapterClient::Observer, observers_, 1911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AdapterPropertyChanged(object_path, property_name)); 1921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // We maintain a pointer to the bus to be able to request proxies for 1951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // new NFC adapters that appear. 1961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dbus::Bus* bus_; 1971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 198f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // List of observers interested in event notifications. 199f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ObserverList<NfcAdapterClient::Observer> observers_; 200f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 2011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Mapping from object paths to object proxies and properties structures that 2021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // were already created by us. 2031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) scoped_ptr<nfc_client_helpers::DBusObjectMap> object_map_; 2041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // The manager client that we listen to events notifications from. 2061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) NfcManagerClient* manager_client_; 2071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Weak pointer factory for generating 'this' pointers that might live longer 2091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // than we do. 2101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Note: This should remain the last member so it'll be destroyed and 2111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // invalidate its weak pointers before any other members are destroyed. 2121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::WeakPtrFactory<NfcAdapterClientImpl> weak_ptr_factory_; 2131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(NfcAdapterClientImpl); 2151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}; 2161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)NfcAdapterClient::NfcAdapterClient() { 2181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 2191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)NfcAdapterClient::~NfcAdapterClient() { 2211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 2221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 223a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)NfcAdapterClient* NfcAdapterClient::Create(NfcManagerClient* manager_client) { 224a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return new NfcAdapterClientImpl(manager_client); 2251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 2261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} // namespace chromeos 228