Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: device/bluetooth/bluetooth_profile_win.h

Issue 236203018: win: Implement Bluetooth server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/bluetooth/bluetooth_profile.cc ('k') | device/bluetooth/bluetooth_profile_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_BLUETOOTH_PROFILE_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
10 #include "device/bluetooth/bluetooth_profile.h" 12 #include "device/bluetooth/bluetooth_profile.h"
11 #include "device/bluetooth/bluetooth_uuid.h" 13 #include "device/bluetooth/bluetooth_uuid.h"
12 #include "net/base/net_log.h" 14 #include "net/base/net_log.h"
15 #include "net/socket/tcp_socket.h"
16
17 namespace net {
18 class IPEndPoint;
19 }
13 20
14 namespace device { 21 namespace device {
15 22
23 class BluetoothAdapter;
24 class BluetoothAdapterWin;
16 class BluetoothDeviceWin; 25 class BluetoothDeviceWin;
17 class BluetoothSocketThreadWin; 26 class BluetoothSocketThreadWin;
27 class BluetoothSocketWin;
18 28
19 class BluetoothProfileWin : public BluetoothProfile { 29 class BluetoothProfileWin : public BluetoothProfile {
20 public: 30 public:
31 typedef base::Callback<void(const std::string&)> ErrorCallback;
32
21 // BluetoothProfile override. 33 // BluetoothProfile override.
22 virtual void Unregister() OVERRIDE; 34 virtual void Unregister() OVERRIDE;
23 virtual void SetConnectionCallback( 35 virtual void SetConnectionCallback(
24 const ConnectionCallback& callback) OVERRIDE; 36 const ConnectionCallback& callback) OVERRIDE;
25 37
26 typedef base::Callback<void(const std::string&)> ErrorCallback; 38 // Called by BluetoothProfile::Register to initialize the profile object
39 // asynchronously.
40 void Init(const BluetoothUUID& uuid,
41 const device::BluetoothProfile::Options& options,
42 const ProfileCallback& callback);
27 43
28 void Connect(const BluetoothDeviceWin* device, 44 void Connect(const BluetoothDeviceWin* device,
29 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, 45 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
30 scoped_refptr<BluetoothSocketThreadWin> socket_thread, 46 scoped_refptr<BluetoothSocketThreadWin> socket_thread,
31 net::NetLog* net_log, 47 net::NetLog* net_log,
32 const net::NetLog::Source& source, 48 const net::NetLog::Source& source,
33 const base::Closure& callback, 49 const base::Closure& callback,
34 const ErrorCallback& error_callback); 50 const ErrorCallback& error_callback);
35 51
36 private: 52 private:
37 friend BluetoothProfile; 53 friend BluetoothProfile;
38 54
39 BluetoothProfileWin(const BluetoothUUID& uuid, const std::string& name); 55 BluetoothProfileWin();
40 virtual ~BluetoothProfileWin(); 56 virtual ~BluetoothProfileWin();
41 57
42 const BluetoothUUID uuid_; 58 // Internal method run to get the adapter object during initialization.
43 const std::string name_; 59 void OnGetAdapter(const ProfileCallback& callback,
60 scoped_refptr<BluetoothAdapter> adapter);
61
62 // Callbacks for |profile_socket_|'s StartService call.
63 void OnRegisterProfileSuccess(const ProfileCallback& callback);
64 void OnRegisterProfileError(const ProfileCallback& callback,
65 const std::string& error_message);
66
67 // Callback when |profile_socket_| accepts a connection.
68 void OnNewConnection(scoped_refptr<BluetoothSocketWin> connected,
69 const net::IPEndPoint& peer_address);
70
71 BluetoothAdapterWin* adapter() const;
72
73 BluetoothUUID uuid_;
74 std::string name_;
75 int rfcomm_channel_;
44 ConnectionCallback connection_callback_; 76 ConnectionCallback connection_callback_;
45 77
78 scoped_refptr<BluetoothAdapter> adapter_;
79 scoped_refptr<BluetoothSocketWin> profile_socket_;
80 base::WeakPtrFactory<BluetoothProfileWin> weak_ptr_factory_;
81
46 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileWin); 82 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileWin);
47 }; 83 };
48 84
49 } // namespace device 85 } // namespace device
50 86
51 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_ 87 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_profile.cc ('k') | device/bluetooth/bluetooth_profile_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698