Index: device/serial/data_sender.h |
diff --git a/device/serial/data_sender.h b/device/serial/data_sender.h |
index 6e5c89e85c0b587643b31f4fc006032844222729..76b16ae6070ee5b7e6bceeb5bfc4843fd1a84bd1 100644 |
--- a/device/serial/data_sender.h |
+++ b/device/serial/data_sender.h |
@@ -16,8 +16,6 @@ |
namespace device { |
-class AsyncWaiter; |
- |
// A DataSender sends data to a DataSink. |
class DataSender : public serial::DataSinkClient, public mojo::ErrorHandler { |
public: |
@@ -26,13 +24,17 @@ class DataSender : public serial::DataSinkClient, public mojo::ErrorHandler { |
SendErrorCallback; |
typedef base::Callback<void()> CancelCallback; |
- // Constructs a DataSender to send data to |sink|, using a data pipe with a |
- // buffer size of |buffer_size|, with connection errors reported as |
- // |fatal_error_value|. |
+ // Constructs a DataSender to send data to |sink|, using a buffer size of |
+ // |buffer_size|, with connection errors reported as |fatal_error_value|. |
DataSender(mojo::InterfacePtr<serial::DataSink> sink, |
uint32_t buffer_size, |
int32_t fatal_error_value); |
+ DataSender(mojo::InterfacePtr<serial::DataSink> sink, |
+ uint32_t buffer_size, |
+ int32_t fatal_error_value, |
+ bool use_data_pipe); |
raymes
2014/10/17 01:55:42
Looks like this was added before changing to suppo
Sam McNally
2014/10/20 05:12:58
Done.
|
+ |
virtual ~DataSender(); |
// Starts an asynchronous send of |data|. If the send completes successfully, |
@@ -57,19 +59,16 @@ class DataSender : public serial::DataSinkClient, public mojo::ErrorHandler { |
virtual void ReportBytesSentAndError( |
uint32_t bytes_sent, |
int32_t error, |
- const mojo::Callback<void(uint32_t)>& callback) override; |
+ const mojo::Callback<void()>& callback) override; |
// mojo::ErrorHandler override. |
virtual void OnConnectionError() override; |
- // Copies data from |pending_sends_| into the data pipe and starts |waiter_| |
- // waiting if the pipe is full. When a PendingSend in |pending_sends_| has |
+ // Sends up to |available_buffer_capacity_| bytes of data from |
+ // |pending_sends_| to |sink_|. When a PendingSend in |pending_sends_| has |
// been fully copied into the data pipe, it moves to |sends_awaiting_ack_|. |
void SendInternal(); |
- // Invoked when |handle_| is ready for writes. Calls SendInternal(). |
- void OnDoneWaiting(MojoResult result); |
- |
// Dispatches a cancel callback if one is pending. |
void RunCancelCallback(); |
@@ -80,27 +79,24 @@ class DataSender : public serial::DataSinkClient, public mojo::ErrorHandler { |
// The control connection to the data sink. |
mojo::InterfacePtr<serial::DataSink> sink_; |
- // The data connection to the data sink. |
- mojo::ScopedDataPipeProducerHandle handle_; |
- |
// The error value to report in the event of a fatal error. |
const int32_t fatal_error_value_; |
- // A waiter used to wait until |handle_| is writable if we are waiting. |
- scoped_ptr<AsyncWaiter> waiter_; |
- |
- // A queue of PendingSend that have not yet been fully written to the data |
- // pipe. |
+ // A queue of PendingSend that have not yet been fully sent to |sink_|. |
std::queue<linked_ptr<PendingSend> > pending_sends_; |
- // A queue of PendingSend that have been written to the data pipe, but have |
- // not yet been acked by the DataSink. |
+ // A queue of PendingSend that have been sent to |sink_|, but have not yet |
+ // been acked by the DataSink. |
std::queue<linked_ptr<PendingSend> > sends_awaiting_ack_; |
// The callback to report cancel completion if a cancel operation is in |
// progress. |
CancelCallback pending_cancel_; |
+ // The number of bytes that have been sent to the sink, but have not been |
+ // acknowledged. |
raymes
2014/10/17 01:55:42
It looks like the description might be slightly wr
Sam McNally
2014/10/20 05:12:58
Done. It originally counted up.
|
+ uint32_t available_buffer_capacity_; |
+ |
// Whether we have encountered a fatal error and shut down. |
bool shut_down_; |