| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SERIAL_DATA_SENDER_H_ | 5 #ifndef DEVICE_SERIAL_DATA_SENDER_H_ |
| 6 #define DEVICE_SERIAL_DATA_SENDER_H_ | 6 #define DEVICE_SERIAL_DATA_SENDER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 typedef base::Callback<void(uint32_t bytes_sent, int32_t error)> | 23 typedef base::Callback<void(uint32_t bytes_sent, int32_t error)> |
| 24 SendErrorCallback; | 24 SendErrorCallback; |
| 25 typedef base::Callback<void()> CancelCallback; | 25 typedef base::Callback<void()> CancelCallback; |
| 26 | 26 |
| 27 // Constructs a DataSender to send data to |sink|, using a buffer size of | 27 // Constructs a DataSender to send data to |sink|, using a buffer size of |
| 28 // |buffer_size|, with connection errors reported as |fatal_error_value|. | 28 // |buffer_size|, with connection errors reported as |fatal_error_value|. |
| 29 DataSender(mojo::InterfacePtr<serial::DataSink> sink, | 29 DataSender(mojo::InterfacePtr<serial::DataSink> sink, |
| 30 uint32_t buffer_size, | 30 uint32_t buffer_size, |
| 31 int32_t fatal_error_value); | 31 int32_t fatal_error_value); |
| 32 | 32 |
| 33 ~DataSender(); | 33 ~DataSender() override; |
| 34 | 34 |
| 35 // Starts an asynchronous send of |data|. If the send completes successfully, | 35 // Starts an asynchronous send of |data|. If the send completes successfully, |
| 36 // |callback| will be called. Otherwise, |error_callback| will be called with | 36 // |callback| will be called. Otherwise, |error_callback| will be called with |
| 37 // the error. If there is a cancel in progress or there has been a connection | 37 // the error. If there is a cancel in progress or there has been a connection |
| 38 // error, this will not start a send and returns false. It is the caller's | 38 // error, this will not start a send and returns false. It is the caller's |
| 39 // responsibility to ensure |data| remains valid until one of |callback| and | 39 // responsibility to ensure |data| remains valid until one of |callback| and |
| 40 // |error_callback| is called. | 40 // |error_callback| is called. |
| 41 bool Send(const base::StringPiece& data, | 41 bool Send(const base::StringPiece& data, |
| 42 const DataSentCallback& callback, | 42 const DataSentCallback& callback, |
| 43 const SendErrorCallback& error_callback); | 43 const SendErrorCallback& error_callback); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 // Whether we have encountered a fatal error and shut down. | 94 // Whether we have encountered a fatal error and shut down. |
| 95 bool shut_down_; | 95 bool shut_down_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(DataSender); | 97 DISALLOW_COPY_AND_ASSIGN(DataSender); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace device | 100 } // namespace device |
| 101 | 101 |
| 102 #endif // DEVICE_SERIAL_DATA_SENDER_H_ | 102 #endif // DEVICE_SERIAL_DATA_SENDER_H_ |
| OLD | NEW |