Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 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_SOCKET_WIN_H_ |
| 6 | #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_WIN_H_ |
| 7 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 8 | #include <WinSock2.h> |
| 9 | |
| 10 | #include <string> |
| 11 | |
| 12 | #include "base/memory/ref_counted.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 13 | #include "device/bluetooth/bluetooth_socket.h" |
| 14 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 15 | namespace net { |
| 16 | |
| 17 | class DrainableIOBuffer; |
| 18 | class GrowableIOBuffer; |
| 19 | |
| 20 | } // namespace net |
| 21 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 22 | namespace device { |
| 23 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 24 | class BluetoothServiceRecord; |
| 25 | |
| 26 | // This class is an implementation of BluetoothSocket class for Windows |
| 27 | // platform. |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 28 | class BluetoothSocketWin : public BluetoothSocket { |
| 29 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 30 | static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( |
| 31 | const BluetoothServiceRecord& service_record); |
| 32 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 33 | // BluetoothSocket override |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 34 | virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE; |
| 35 | virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE; |
| 36 | virtual std::string GetLastErrorMessage() const OVERRIDE; |
| 37 | |
| 38 | protected: |
| 39 | virtual ~BluetoothSocketWin(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 40 | |
| 41 | private: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 42 | explicit BluetoothSocketWin(SOCKET fd); |
| 43 | |
| 44 | const SOCKET fd_; |
| 45 | std::string error_message_; |
| 46 | |
| 47 | DISALLOW_COPY_AND_ASSIGN(BluetoothSocketWin); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace device |
| 51 | |
| 52 | #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_WIN_H_ |