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 module device.serial; | 5 module device.serial; |
6 | 6 |
7 [Client=DataSourceClient] | |
8 interface DataSource { | 7 interface DataSource { |
9 // Initializes this DataSource with the amount of data its client will | 8 // Initializes this DataSource with the amount of data its client will |
10 // buffer. | 9 // buffer. |
11 Init(uint32 buffer_size); | 10 Init(uint32 buffer_size); |
12 | 11 |
13 // Resumes sending data after it has been stopped due to an error. | 12 // Resumes sending data after it has been stopped due to an error. |
14 Resume(); | 13 Resume(); |
15 | 14 |
16 // Reports that |bytes_sent| bytes have been successfully passed to the | 15 // Reports that |bytes_sent| bytes have been successfully passed to the |
17 // client. | 16 // client. |
18 ReportBytesReceived(uint32 bytes_sent); | 17 ReportBytesReceived(uint32 bytes_sent); |
19 }; | 18 }; |
20 | 19 |
21 interface DataSourceClient { | 20 interface DataSourceClient { |
22 // Invoked to report |error| from the DataSource. No further bytes will be | 21 // Invoked to report |error| from the DataSource. No further bytes will be |
23 // transmitted from the DataSource until Resume() is called. | 22 // transmitted from the DataSource until Resume() is called. |
24 OnError(int32 error); | 23 OnError(int32 error); |
25 | 24 |
26 // Invoked to transmit data from the DataSource. | 25 // Invoked to transmit data from the DataSource. |
27 OnData(array<uint8> data); | 26 OnData(array<uint8> data); |
28 }; | 27 }; |
29 | 28 |
30 [Client=DataSinkClient] | |
31 interface DataSink { | 29 interface DataSink { |
32 // Initializes this DataSink with the amount of data it is expected to | |
33 // buffer. | |
34 Init(uint32 buffer_size); | |
35 | |
36 // Requests the cancellation of any data that has been written to the pipe, | 30 // Requests the cancellation of any data that has been written to the pipe, |
37 // but has not yet been sent to the sink. | 31 // but has not yet been sent to the sink. |
38 Cancel(int32 error); | 32 Cancel(int32 error); |
39 | 33 |
40 // Invoked to pass |data| to the sink. | 34 // Invoked to pass |data| to the sink. The response contains the number of |
41 OnData(array<uint8> data); | 35 // bytes successfully sent and an optional error. If |error| is zero, |
| 36 // |bytes_sent| will the size of |data|. |
| 37 OnData(array<uint8> data) => (uint32 bytes_sent, int32 error); |
| 38 |
| 39 // Called to clear the error and resume data transmission after an error |
| 40 // occurs. After an error is reported in response to an OnData until |
| 41 // ClearError is called, any further OnData calls will report the same error |
| 42 // as the first error response. |
| 43 ClearError(); |
42 }; | 44 }; |
43 | |
44 interface DataSinkClient { | |
45 // Reports that the sink has successfully received |bytes_sent| bytes of data. | |
46 ReportBytesSent(uint32 bytes_sent); | |
47 | |
48 // Reports that the sink has received |bytes_sent| bytes of data (possibly 0) | |
49 // and encountered an error: |error|. Any OnData messages received by the | |
50 // DataSink before the response will be discarded. The client should respond | |
51 // when it is ready to resume sending data. | |
52 ReportBytesSentAndError(uint32 bytes_sent, int32 error) => (); | |
53 }; | |
OLD | NEW |