Turning in DCHECK to test for illegal visibility / opacity flag combination
[chromium-blink-merge.git] / device / bluetooth / bluetooth_profile_win.h
blob0222bfdee40ec8a57aee7328cd7f65eb624f009d
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "device/bluetooth/bluetooth_profile.h"
13 #include "device/bluetooth/bluetooth_uuid.h"
14 #include "net/base/net_log.h"
15 #include "net/socket/tcp_socket.h"
17 namespace net {
18 class IPEndPoint;
21 namespace device {
23 class BluetoothAdapter;
24 class BluetoothAdapterWin;
25 class BluetoothDeviceWin;
26 class BluetoothSocketThread;
27 class BluetoothSocketWin;
29 class BluetoothProfileWin : public BluetoothProfile {
30 public:
31 typedef base::Callback<void(const std::string&)> ErrorCallback;
33 // BluetoothProfile override.
34 virtual void Unregister() OVERRIDE;
35 virtual void SetConnectionCallback(
36 const ConnectionCallback& callback) OVERRIDE;
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);
44 void Connect(const BluetoothDeviceWin* device,
45 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
46 scoped_refptr<BluetoothSocketThread> socket_thread,
47 net::NetLog* net_log,
48 const net::NetLog::Source& source,
49 const base::Closure& callback,
50 const ErrorCallback& error_callback);
52 private:
53 friend BluetoothProfile;
55 BluetoothProfileWin();
56 virtual ~BluetoothProfileWin();
58 // Internal method run to get the adapter object during initialization.
59 void OnGetAdapter(const ProfileCallback& callback,
60 scoped_refptr<BluetoothAdapter> adapter);
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);
67 // Callback when |profile_socket_| accepts a connection.
68 void OnNewConnection(scoped_refptr<BluetoothSocketWin> connected,
69 const net::IPEndPoint& peer_address);
71 BluetoothAdapterWin* adapter() const;
73 BluetoothUUID uuid_;
74 std::string name_;
75 int rfcomm_channel_;
76 ConnectionCallback connection_callback_;
78 scoped_refptr<BluetoothAdapter> adapter_;
79 scoped_refptr<BluetoothSocketWin> profile_socket_;
80 base::WeakPtrFactory<BluetoothProfileWin> weak_ptr_factory_;
82 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileWin);
85 } // namespace device
87 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_WIN_H_