1e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 2e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// found in the LICENSE file. 4e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 5e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "chromeos/dbus/fake_bluetooth_gatt_service_service_provider.h" 6e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 7e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "base/logging.h" 8e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "chromeos/dbus/dbus_thread_manager.h" 9e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" 10e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 11e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochnamespace chromeos { 12e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 13e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen MurdochFakeBluetoothGattServiceServiceProvider:: 14e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch FakeBluetoothGattServiceServiceProvider( 15e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch const dbus::ObjectPath& object_path, 16e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch const std::string& uuid, 17e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch const std::vector<dbus::ObjectPath>& includes) 18e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch : object_path_(object_path), 19e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch uuid_(uuid), 20e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch includes_(includes) { 21e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch VLOG(1) << "Creating Bluetooth GATT service: " << object_path_.value(); 22e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 23e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 24e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch static_cast<FakeBluetoothGattManagerClient*>( 25e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch DBusThreadManager::Get()->GetBluetoothGattManagerClient()); 26e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch fake_bluetooth_gatt_manager_client->RegisterServiceServiceProvider(this); 27e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch} 28e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 29e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen MurdochFakeBluetoothGattServiceServiceProvider:: 30e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch ~FakeBluetoothGattServiceServiceProvider() { 31e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch VLOG(1) << "Cleaning up Bluetooth GATT service: " << object_path_.value(); 32e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 33e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 34e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch static_cast<FakeBluetoothGattManagerClient*>( 35e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch DBusThreadManager::Get()->GetBluetoothGattManagerClient()); 36e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch fake_bluetooth_gatt_manager_client->UnregisterServiceServiceProvider(this); 37e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch} 38e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 39e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch} // namespace chromeos 40