| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module device.serial; |
| |
| [Client=DataSourceClient] |
| interface DataSource { |
| // Initializes this DataSource with the amount of data its client will |
| // buffer. |
| Init(uint32 buffer_size); |
| |
| // Resumes sending data after it has been stopped due to an error. |
| Resume(); |
| |
| // Reports that |bytes_sent| bytes have been successfully passed to the |
| // client. |
| ReportBytesReceived(uint32 bytes_sent); |
| }; |
| |
| interface DataSourceClient { |
| // Invoked to report |error| from the DataSource. No further bytes will be |
| // transmitted from the DataSource until Resume() is called. |
| OnError(int32 error); |
| |
| // Invoked to transmit data from the DataSource. |
| OnData(array<uint8> data); |
| }; |
| |
| [Client=DataSinkClient] |
| interface DataSink { |
| // Initializes this DataSink with the amount of data it is expected to |
| // buffer. |
| Init(uint32 buffer_size); |
| |
| // Requests the cancellation of any data that has been written to the pipe, |
| // but has not yet been sent to the sink. |
| Cancel(int32 error); |
| |
| // Invoked to pass |data| to the sink. |
| OnData(array<uint8> data); |
| }; |
| |
| interface DataSinkClient { |
| // Reports that the sink has successfully received |bytes_sent| bytes of data. |
| ReportBytesSent(uint32 bytes_sent); |
| |
| // Reports that the sink has received |bytes_sent| bytes of data (possibly 0) |
| // and encountered an error: |error|. Any OnData messages received by the |
| // DataSink before the response will be discarded. The client should respond |
| // when it is ready to resume sending data. |
| ReportBytesSentAndError(uint32 bytes_sent, int32 error) => (); |
| }; |