Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_profile_service_provider.h
blob2c98048c5a9895d83bad733f3efe85921aa07595
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.
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_
8 #include "base/bind.h"
9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/bluetooth_profile_service_provider.h"
13 #include "dbus/file_descriptor.h"
14 #include "dbus/object_path.h"
16 namespace chromeos {
18 // FakeBluetoothProfileServiceProvider simulates the behavior of a local
19 // Bluetooth agent object and is used both in test cases in place of a
20 // mock and on the Linux desktop.
22 // This class is only called from the dbus origin thread and is not thread-safe.
23 class CHROMEOS_EXPORT FakeBluetoothProfileServiceProvider
24 : public BluetoothProfileServiceProvider {
25 public:
26 FakeBluetoothProfileServiceProvider(const dbus::ObjectPath& object_path,
27 Delegate* delegate);
28 ~FakeBluetoothProfileServiceProvider() override;
30 // Each of these calls the equivalent
31 // BluetoothProfileServiceProvider::Delegate method on the object passed on
32 // construction.
33 void Released();
34 void NewConnection(const dbus::ObjectPath& device_path,
35 scoped_ptr<dbus::FileDescriptor> fd,
36 const Delegate::Options& options,
37 const Delegate::ConfirmationCallback& callback);
38 void RequestDisconnection(const dbus::ObjectPath& device_path,
39 const Delegate::ConfirmationCallback& callback);
40 void Cancel();
42 const dbus::ObjectPath& object_path() const { return object_path_; }
44 private:
45 friend class FakeBluetoothProfileManagerClient;
47 // D-Bus object path we are faking.
48 dbus::ObjectPath object_path_;
50 // All incoming method calls are passed on to the Delegate and a callback
51 // passed to generate the reply. |delegate_| is generally the object that
52 // owns this one, and must outlive it.
53 Delegate* delegate_;
55 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothProfileServiceProvider);
58 } // namespace chromeos
60 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_