OLD | NEW |
---|---|
(Empty) | |
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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_EXPERIMENTAL_CHROMEOS_H_ | |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_EXPERIMENTAL_CHROMEOS_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/callback.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "chromeos/chromeos_export.h" | |
15 #include "chromeos/dbus/experimental_bluetooth_profile_service_provider.h" | |
16 #include "dbus/object_path.h" | |
17 #include "device/bluetooth/bluetooth_profile.h" | |
18 | |
19 namespace dbus { | |
20 | |
21 class FileDescriptor; | |
22 | |
23 } // namespace dbus | |
24 | |
25 namespace device { | |
26 | |
27 class BluetoothAdapter; | |
28 | |
29 } // namespace device | |
30 | |
31 namespace chromeos { | |
32 | |
33 class CHROMEOS_EXPORT BluetoothProfileExperimentalChromeOS | |
satorux1
2013/05/07 08:07:16
class comment is missing. please add some.
| |
34 : public device::BluetoothProfile, | |
35 private ExperimentalBluetoothProfileServiceProvider::Delegate { | |
36 public: | |
37 // BluetoothProfile override. | |
38 virtual void Unregister() OVERRIDE; | |
39 virtual void SetConnectionCallback( | |
40 const ConnectionCallback& callback) OVERRIDE; | |
41 | |
42 // Return the UUID of the profile. | |
43 const std::string& uuid() const { return uuid_; } | |
44 | |
45 private: | |
46 friend BluetoothProfile; | |
47 | |
48 BluetoothProfileExperimentalChromeOS(); | |
49 virtual ~BluetoothProfileExperimentalChromeOS(); | |
50 | |
51 // Called by BluetoothProfile::Register to initialize the profile object | |
52 // asynchronously. |uuid|, |options| and |callback| are the arguments to | |
53 // BluetoothProfile::Register. | |
54 void Init(const std::string& uuid, | |
55 const device::BluetoothProfile::Options& options, | |
56 const ProfileCallback& callback); | |
57 | |
58 // ExperimentalBluetoothProfileServiceProvider::Delegate override. | |
59 virtual void Release() OVERRIDE; | |
60 virtual void NewConnection( | |
61 const dbus::ObjectPath& device_path, | |
62 scoped_ptr<dbus::FileDescriptor> fd, | |
63 const ExperimentalBluetoothProfileServiceProvider::Delegate::Options& | |
64 options, | |
65 const ConfirmationCallback& callback) OVERRIDE; | |
66 virtual void RequestDisconnection( | |
67 const dbus::ObjectPath& device_path, | |
68 const ConfirmationCallback& callback) OVERRIDE; | |
69 virtual void Cancel() OVERRIDE; | |
70 | |
71 // Called by dbus:: on completion of the D-Bus method call to register the | |
72 // profile object. | |
73 void OnRegisterProfile(const ProfileCallback& callback); | |
74 void OnRegisterProfileError(const ProfileCallback& callback, | |
75 const std::string& error_name, | |
76 const std::string& error_message); | |
77 | |
78 // Called by dbus:: on completion of the D-Bus method call to unregister | |
79 // the profile object. | |
80 void OnUnregisterProfile(); | |
81 void OnUnregisterProfileError(const std::string& error_name, | |
82 const std::string& error_message); | |
83 | |
84 // Method run once the file descriptor has been validated in order to get | |
85 // the default adapter, and method run once the default adapter has been | |
86 // obtained in order to get the device object to be passed to the connection | |
87 // callback. | |
88 // | |
89 // The |fd| argument is moved compared to the NewConnection() call since it | |
90 // becomes the result of a PostTaskAndReplyWithResult() call. | |
91 void GetAdapter( | |
92 const dbus::ObjectPath& device_path, | |
93 const ExperimentalBluetoothProfileServiceProvider::Delegate::Options& | |
94 options, | |
95 const ConfirmationCallback& callback, | |
96 scoped_ptr<dbus::FileDescriptor> fd); | |
97 void OnGetAdapter( | |
98 const dbus::ObjectPath& device_path, | |
99 const ExperimentalBluetoothProfileServiceProvider::Delegate::Options& | |
100 options, | |
101 const ConfirmationCallback& callback, | |
102 scoped_ptr<dbus::FileDescriptor> fd, | |
103 scoped_refptr<device::BluetoothAdapter>); | |
104 | |
105 // UUID of the profile passed during initialization. | |
106 std::string uuid_; | |
107 | |
108 // Object path of the local profile D-Bus object. | |
109 dbus::ObjectPath object_path_; | |
110 | |
111 // Local profile D-Bus object used for receiving profile delegate methods | |
112 // from BlueZ. | |
113 scoped_ptr<ExperimentalBluetoothProfileServiceProvider> profile_; | |
114 | |
115 // Callback used on both outgoing and incoming connections to pass the | |
116 // connected socket to profile object owner. | |
117 ConnectionCallback connection_callback_; | |
118 | |
119 // Note: This should remain the last member so it'll be destroyed and | |
120 // invalidate its weak pointers before any other members are destroyed. | |
121 base::WeakPtrFactory<BluetoothProfileExperimentalChromeOS> weak_ptr_factory_; | |
122 | |
123 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileExperimentalChromeOS); | |
124 }; | |
125 | |
126 } // namespace chromeos | |
127 | |
128 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_EXPERIMENTAL_CHROMEOS_H_ | |
OLD | NEW |