Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 typedef base::Callback<void(const std::string& error_message)> | 34 typedef base::Callback<void(const std::string& error_message)> |
| 35 ErrorCompletionCallback; | 35 ErrorCompletionCallback; |
| 36 typedef base::Callback<void(ErrorReason, const std::string& error_message)> | 36 typedef base::Callback<void(ErrorReason, const std::string& error_message)> |
| 37 ReceiveErrorCompletionCallback; | 37 ReceiveErrorCompletionCallback; |
| 38 | 38 |
| 39 // Destroys resources associated with the socket. After calling this method, | 39 // Destroys resources associated with the socket. After calling this method, |
| 40 // it is illegal to call any method on this socket instance (except for the | 40 // it is illegal to call any method on this socket instance (except for the |
| 41 // desctrutor via Release). | 41 // desctrutor via Release). |
| 42 virtual void Close() = 0; | 42 virtual void Close() = 0; |
| 43 | 43 |
| 44 // Gracefully disconnects the socket and calls |callback| upon completion. | 44 // Gracefully disconnects the socket and calls |callback| upon completion. |
|
armansito
2014/05/01 00:14:25
If you're set on using |success_callback| as the n
keybuk
2014/05/01 00:24:09
ACK
| |
| 45 // There is no failure case, as this is a best effort operation. | 45 // There is no failure case, as this is a best effort operation. |
| 46 virtual void Disconnect(const base::Closure& callback) = 0; | 46 virtual void Disconnect(const base::Closure& success_callback) = 0; |
|
armansito
2014/05/01 00:14:25
Might as well leave it as |callback|, since it is
keybuk
2014/05/01 00:24:09
yeah I had added an error_callback but decided not
| |
| 47 | 47 |
| 48 // Receives data from the socket and calls |success_callback| when data is | 48 // Receives data from the socket and calls |success_callback| when data is |
| 49 // available. |buffer_size| specifies the maximum number of bytes that can be | 49 // available. |buffer_size| specifies the maximum number of bytes that can be |
| 50 // received. If an error occurs, calls |error_callback| with a reason and an | 50 // received. If an error occurs, calls |error_callback| with a reason and an |
| 51 // error message. | 51 // error message. |
| 52 virtual void Receive( | 52 virtual void Receive( |
| 53 int buffer_size, | 53 int buffer_size, |
| 54 const ReceiveCompletionCallback& success_callback, | 54 const ReceiveCompletionCallback& success_callback, |
| 55 const ReceiveErrorCompletionCallback& error_callback) = 0; | 55 const ReceiveErrorCompletionCallback& error_callback) = 0; |
| 56 | 56 |
| 57 // Sends |buffer| to the socket and calls |success_callback| when data has | 57 // Sends |buffer| to the socket and calls |success_callback| when data has |
| 58 // been successfully sent. |buffer_size| is the number of bytes contained in | 58 // been successfully sent. |buffer_size| is the number of bytes contained in |
| 59 // |buffer|. If an error occurs, calls |error_callback| with an error message. | 59 // |buffer|. If an error occurs, calls |error_callback| with an error message. |
| 60 virtual void Send(scoped_refptr<net::IOBuffer> buffer, | 60 virtual void Send(scoped_refptr<net::IOBuffer> buffer, |
| 61 int buffer_size, | 61 int buffer_size, |
| 62 const SendCompletionCallback& success_callback, | 62 const SendCompletionCallback& success_callback, |
| 63 const ErrorCompletionCallback& error_callback) = 0; | 63 const ErrorCompletionCallback& error_callback) = 0; |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 friend class base::RefCountedThreadSafe<BluetoothSocket>; | 66 friend class base::RefCountedThreadSafe<BluetoothSocket>; |
| 67 virtual ~BluetoothSocket(); | 67 virtual ~BluetoothSocket(); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace device | 70 } // namespace device |
| 71 | 71 |
| 72 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_ | 72 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_H_ |
| OLD | NEW |