OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |
6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "dbus/file_descriptor.h" | |
14 #include "dbus/object_path.h" | 13 #include "dbus/object_path.h" |
15 #include "device/bluetooth/bluetooth_export.h" | 14 #include "device/bluetooth/bluetooth_export.h" |
16 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" | 15 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" |
17 | 16 |
18 namespace bluez { | 17 namespace bluez { |
19 | 18 |
20 // FakeBluetoothProfileServiceProvider simulates the behavior of a local | 19 // FakeBluetoothProfileServiceProvider simulates the behavior of a local |
21 // Bluetooth agent object and is used both in test cases in place of a | 20 // Bluetooth agent object and is used both in test cases in place of a |
22 // mock and on the Linux desktop. | 21 // mock and on the Linux desktop. |
23 // | 22 // |
24 // This class is only called from the dbus origin thread and is not thread-safe. | 23 // This class is only called from the dbus origin thread and is not thread-safe. |
25 class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileServiceProvider | 24 class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileServiceProvider |
26 : public BluetoothProfileServiceProvider { | 25 : public BluetoothProfileServiceProvider { |
27 public: | 26 public: |
28 FakeBluetoothProfileServiceProvider(const dbus::ObjectPath& object_path, | 27 FakeBluetoothProfileServiceProvider(const dbus::ObjectPath& object_path, |
29 Delegate* delegate); | 28 Delegate* delegate); |
30 ~FakeBluetoothProfileServiceProvider() override; | 29 ~FakeBluetoothProfileServiceProvider() override; |
31 | 30 |
32 // Each of these calls the equivalent | 31 // Each of these calls the equivalent |
33 // BluetoothProfileServiceProvider::Delegate method on the object passed on | 32 // BluetoothProfileServiceProvider::Delegate method on the object passed on |
34 // construction. | 33 // construction. |
35 void Released(); | 34 void Released(); |
36 void NewConnection(const dbus::ObjectPath& device_path, | 35 void NewConnection(const dbus::ObjectPath& device_path, |
37 std::unique_ptr<dbus::FileDescriptor> fd, | 36 base::ScopedFD fd, |
38 const Delegate::Options& options, | 37 const Delegate::Options& options, |
39 const Delegate::ConfirmationCallback& callback); | 38 const Delegate::ConfirmationCallback& callback); |
40 void RequestDisconnection(const dbus::ObjectPath& device_path, | 39 void RequestDisconnection(const dbus::ObjectPath& device_path, |
41 const Delegate::ConfirmationCallback& callback); | 40 const Delegate::ConfirmationCallback& callback); |
42 void Cancel(); | 41 void Cancel(); |
43 | 42 |
44 const dbus::ObjectPath& object_path() const { return object_path_; } | 43 const dbus::ObjectPath& object_path() const { return object_path_; } |
45 | 44 |
46 private: | 45 private: |
47 friend class FakeBluetoothProfileManagerClient; | 46 friend class FakeBluetoothProfileManagerClient; |
48 | 47 |
49 // D-Bus object path we are faking. | 48 // D-Bus object path we are faking. |
50 dbus::ObjectPath object_path_; | 49 dbus::ObjectPath object_path_; |
51 | 50 |
52 // All incoming method calls are passed on to the Delegate and a callback | 51 // All incoming method calls are passed on to the Delegate and a callback |
53 // passed to generate the reply. |delegate_| is generally the object that | 52 // passed to generate the reply. |delegate_| is generally the object that |
54 // owns this one, and must outlive it. | 53 // owns this one, and must outlive it. |
55 Delegate* delegate_; | 54 Delegate* delegate_; |
56 | 55 |
57 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothProfileServiceProvider); | 56 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothProfileServiceProvider); |
58 }; | 57 }; |
59 | 58 |
60 } // namespace bluez | 59 } // namespace bluez |
61 | 60 |
62 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ | 61 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |
OLD | NEW |