Home | History | Annotate | Download | only in dbus
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h"
      6 
      7 #include "chromeos/dbus/dbus_thread_manager.h"
      8 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
      9 #include "dbus/object_path.h"
     10 
     11 namespace chromeos {
     12 
     13 FakeBluetoothProfileServiceProvider::FakeBluetoothProfileServiceProvider(
     14     const dbus::ObjectPath& object_path,
     15     Delegate* delegate)
     16     : object_path_(object_path),
     17       delegate_(delegate) {
     18   VLOG(1) << "Creating Bluetooth Profile: " << object_path_.value();
     19 
     20   FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client =
     21       static_cast<FakeBluetoothProfileManagerClient*>(
     22           DBusThreadManager::Get()->GetBluetoothProfileManagerClient());
     23   fake_bluetooth_profile_manager_client->RegisterProfileServiceProvider(this);
     24 }
     25 
     26 FakeBluetoothProfileServiceProvider::~FakeBluetoothProfileServiceProvider() {
     27   VLOG(1) << "Cleaning up Bluetooth Profile: " << object_path_.value();
     28 
     29   FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client =
     30       static_cast<FakeBluetoothProfileManagerClient*>(
     31           DBusThreadManager::Get()->GetBluetoothProfileManagerClient());
     32   fake_bluetooth_profile_manager_client->UnregisterProfileServiceProvider(this);
     33 }
     34 
     35 void FakeBluetoothProfileServiceProvider::Release() {
     36   VLOG(1) << object_path_.value() << ": Release";
     37   delegate_->Release();
     38 }
     39 
     40 void FakeBluetoothProfileServiceProvider::NewConnection(
     41     const dbus::ObjectPath& device_path,
     42     scoped_ptr<dbus::FileDescriptor> fd,
     43     const Delegate::Options& options,
     44     const Delegate::ConfirmationCallback& callback) {
     45   VLOG(1) << object_path_.value() << ": NewConnection for "
     46           << device_path.value();
     47   delegate_->NewConnection(device_path, fd.Pass(), options, callback);
     48 }
     49 
     50 void FakeBluetoothProfileServiceProvider::RequestDisconnection(
     51     const dbus::ObjectPath& device_path,
     52     const Delegate::ConfirmationCallback& callback) {
     53   VLOG(1) << object_path_.value() << ": RequestDisconnection for "
     54           << device_path.value();
     55   delegate_->RequestDisconnection(device_path, callback);
     56 }
     57 
     58 void FakeBluetoothProfileServiceProvider::Cancel() {
     59   VLOG(1) << object_path_.value() << ": Cancel";
     60   delegate_->Cancel();
     61 }
     62 
     63 }  // namespace chromeos
     64