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] | 7 [Client=DataSourceClient] |
8 interface DataSource { | 8 interface DataSource { |
9 // Initializes this DataSource with a data pipe handle to use for data | 9 // Initializes this DataSource with the amount of data its client will |
10 // transmission. | 10 // buffer. |
11 Init(handle<data_pipe_producer> producer_handle); | 11 Init(uint32 buffer_size); |
12 | 12 |
13 // Resumes sending data after it has been stopped due to an error. | 13 // Resumes sending data after it has been stopped due to an error. |
14 Resume(); | 14 Resume(); |
15 | |
16 AckData(uint32 bytes_received); | |
raymes
2014/10/17 02:11:09
Please add a comment here. Does it make more sense
raymes
2014/10/17 04:04:45
Also should we name this consistently with ReportB
Sam McNally
2014/10/20 05:12:59
It does, but there could be a stash before the res
Sam McNally
2014/10/20 05:12:59
Done.
| |
15 }; | 17 }; |
16 | 18 |
17 interface DataSourceClient { | 19 interface DataSourceClient { |
18 // Invoked to report |error| from the DataSource, at |error_location| bytes | 20 // Invoked to report |error| from the DataSource. No further bytes will be |
19 // into the data stream. No further bytes beyond |error_location| will be | |
20 // transmitted from the DataSource until Resume() is called. | 21 // transmitted from the DataSource until Resume() is called. |
21 OnError(uint32 error_location, int32 error); | 22 OnError(int32 error); |
23 | |
24 // Invoked to transmit data from the DataSource. | |
25 OnData(array<uint8> data); | |
22 }; | 26 }; |
23 | 27 |
24 [Client=DataSinkClient] | 28 [Client=DataSinkClient] |
25 interface DataSink { | 29 interface DataSink { |
26 // Initializes this DataSink with a data pipe handle to use for data | 30 // Initializes this DataSink with the amount of data it is expected to |
27 // transmission. | 31 // buffer. |
28 Init(handle<data_pipe_consumer> consumer_handle); | 32 Init(uint32 buffer_size); |
29 | 33 |
30 // Requests the cancellation of any data that has been written to the pipe, | 34 // Requests the cancellation of any data that has been written to the pipe, |
31 // but has not yet been sent to the sink. | 35 // but has not yet been sent to the sink. |
32 Cancel(int32 error); | 36 Cancel(int32 error); |
37 | |
38 // Invoked to pass |data| to the sink. | |
39 AcceptData(array<uint8> data); | |
raymes
2014/10/17 02:11:10
nit, optional: should we name this consistently wi
Sam McNally
2014/10/20 05:12:59
Done.
| |
33 }; | 40 }; |
34 | 41 |
35 interface DataSinkClient { | 42 interface DataSinkClient { |
36 // Reports that the sink has successfully received |bytes_sent| bytes of data. | 43 // Reports that the sink has successfully received |bytes_sent| bytes of data. |
37 ReportBytesSent(uint32 bytes_sent); | 44 ReportBytesSent(uint32 bytes_sent); |
38 | 45 |
39 // Reports that the sink has received |bytes_sent| bytes of data (possibly 0) | 46 // Reports that the sink has received |bytes_sent| bytes of data (possibly 0) |
40 // and encountered an error: |error|. The client should respond with | 47 // and encountered an error: |error|. The client should respond with |
41 // |bytes_to_flush|, the number of bytes enqueued in the data pipe but not yet | 48 // |bytes_to_flush|, the number of bytes enqueued in the data pipe but not yet |
raymes
2014/10/17 02:11:10
This comment is out of date now. I'm curious why i
raymes
2014/10/17 03:16:24
I guess the callback basically ensures that all th
Sam McNally
2014/10/20 05:12:59
The sends in the pipeline are all cancelled. Other
| |
42 // acked so the correct number of bytes can be flushed from the pipe. | 49 // acked so the correct number of bytes can be flushed from the pipe. |
43 ReportBytesSentAndError(uint32 bytes_sent, int32 error) => (uint32 bytes_to_fl ush); | 50 ReportBytesSentAndError(uint32 bytes_sent, int32 error) => (); |
44 }; | 51 }; |
45 | 52 |
46 } | 53 } |
OLD | NEW |