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

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

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 6 years, 9 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
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_SOCKET_MAC_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "device/bluetooth/bluetooth_socket.h" 11 #include "device/bluetooth/bluetooth_socket.h"
12 12
13 #ifdef __OBJC__ 13 #ifdef __OBJC__
14 @class BluetoothRFCOMMChannelDelegate; 14 @class BluetoothRFCOMMChannelDelegate;
15 @class IOBluetoothRFCOMMChannel; 15 @class IOBluetoothRFCOMMChannel;
16 @class IOBluetoothSDPServiceRecord; 16 @class IOBluetoothSDPServiceRecord;
17 #else 17 #else
18 class BluetoothRFCOMMChannelDelegate; 18 class BluetoothRFCOMMChannelDelegate;
19 class IOBluetoothRFCOMMChannel; 19 class IOBluetoothRFCOMMChannel;
20 class IOBluetoothSDPServiceRecord; 20 class IOBluetoothSDPServiceRecord;
21 #endif 21 #endif
22 22
23 namespace net { 23 namespace net {
24 24 class IOBuffer;
25 class DrainableIOBuffer;
26 class GrowableIOBuffer;
27
28 } // namespace net 25 } // namespace net
29 26
30 namespace device { 27 namespace device {
31 28
32 class BluetoothServiceRecord; 29 class BluetoothServiceRecord;
33 30
34 // This class is an implementation of BluetoothSocket class for OSX platform. 31 // This class is an implementation of BluetoothSocket class for OSX platform.
35 class BluetoothSocketMac : public BluetoothSocket { 32 class BluetoothSocketMac : public BluetoothSocket {
36 public: 33 public:
37 // TODO(youngki): This method is deprecated; remove this method when 34 // TODO(youngki): This method is deprecated; remove this method when
38 // BluetoothServiceRecord is removed. 35 // BluetoothServiceRecord is removed.
39 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( 36 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket(
40 const BluetoothServiceRecord& service_record); 37 const BluetoothServiceRecord& service_record);
41 38
42 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket( 39 static scoped_refptr<BluetoothSocket> CreateBluetoothSocket(
43 IOBluetoothSDPServiceRecord* record); 40 IOBluetoothSDPServiceRecord* record);
44 41
45 // BluetoothSocket override 42 // BluetoothSocket override
46 virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE; 43 virtual void Connect(const base::Closure& success_callback,
47 virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE; 44 const ErrorCompletionCallback& error_callback) OVERRIDE;
48 virtual std::string GetLastErrorMessage() const OVERRIDE; 45 virtual void Disconnect(const base::Closure& callback) OVERRIDE;
46 virtual void Receive(int count,
47 const ReceiveCompletionCallback& success_callback,
48 const ReceiveErrorCompletionCallback& error_callback)
49 OVERRIDE;
50 virtual void Send(scoped_refptr<net::IOBuffer> buffer,
51 int buffer_size,
52 const SendCompletionCallback& success_callback,
53 const ErrorCompletionCallback& error_callback) OVERRIDE;
49 54
50 // called by BluetoothRFCOMMChannelDelegate. 55 // called by BluetoothRFCOMMChannelDelegate.
51 void OnDataReceived(IOBluetoothRFCOMMChannel* rfcomm_channel, 56 void OnDataReceived(IOBluetoothRFCOMMChannel* rfcomm_channel,
52 void* data, 57 void* data,
53 size_t length); 58 size_t length);
54 59
55 protected: 60 protected:
56 virtual ~BluetoothSocketMac(); 61 virtual ~BluetoothSocketMac();
57 62
58 private: 63 private:
59 explicit BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel); 64 explicit BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel);
60 65
61 void ResetIncomingDataBuffer(); 66 void ResetIncomingDataBuffer();
62 67
63 IOBluetoothRFCOMMChannel* rfcomm_channel_; 68 IOBluetoothRFCOMMChannel* rfcomm_channel_;
64 BluetoothRFCOMMChannelDelegate* delegate_; 69 BluetoothRFCOMMChannelDelegate* delegate_;
65 scoped_refptr<net::GrowableIOBuffer> incoming_data_buffer_; 70 scoped_refptr<net::GrowableIOBuffer> incoming_data_buffer_;
66 std::string error_message_; 71 std::string error_message_;
67 72
68 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac); 73 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketMac);
69 }; 74 };
70 75
71 } // namespace device 76 } // namespace device
72 77
73 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_ 78 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698