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_SINK_RECEIVER_H_ | 5 #ifndef DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ |
6 #define DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ | 6 #define DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // Marks |bytes_read| bytes as being read. | 72 // Marks |bytes_read| bytes as being read. |
73 bool DoneInternal(uint32_t bytes_read); | 73 bool DoneInternal(uint32_t bytes_read); |
74 | 74 |
75 // Reports an error to the client. | 75 // Reports an error to the client. |
76 void ReportError(uint32_t bytes_read, int32_t error); | 76 void ReportError(uint32_t bytes_read, int32_t error); |
77 | 77 |
78 // Reports a fatal error to the client and shuts down. | 78 // Reports a fatal error to the client and shuts down. |
79 void DispatchFatalError(); | 79 void DispatchFatalError(); |
80 | 80 |
81 mojo::Binding<serial::DataSink> binding_; | |
82 | |
83 // The callback to call when there is data ready to read. | 81 // The callback to call when there is data ready to read. |
84 const ReadyCallback ready_callback_; | 82 const ReadyCallback ready_callback_; |
85 | 83 |
86 // The callback to call when the client has requested cancellation. | 84 // The callback to call when the client has requested cancellation. |
87 const CancelCallback cancel_callback_; | 85 const CancelCallback cancel_callback_; |
88 | 86 |
89 // The callback to call if a fatal error occurs. | 87 // The callback to call if a fatal error occurs. |
90 const ErrorCallback error_callback_; | 88 const ErrorCallback error_callback_; |
91 | 89 |
92 // The current error that has not been cleared by a ClearError message.. | 90 // The current error that has not been cleared by a ClearError message.. |
93 int32_t current_error_; | 91 int32_t current_error_; |
94 | 92 |
95 // The buffer passed to |ready_callback_| if one exists. This is not owned, | 93 // The buffer passed to |ready_callback_| if one exists. This is not owned, |
96 // but the Buffer will call Done or DoneWithError before being deleted. | 94 // but the Buffer will call Done or DoneWithError before being deleted. |
97 Buffer* buffer_in_use_; | 95 Buffer* buffer_in_use_; |
98 | 96 |
99 // The data we have received from the client that has not been passed to | 97 // The data we have received from the client that has not been passed to |
100 // |ready_callback_|. | 98 // |ready_callback_|. |
101 std::queue<linked_ptr<DataFrame>> pending_data_buffers_; | 99 std::queue<linked_ptr<DataFrame>> pending_data_buffers_; |
102 | 100 |
103 // Whether we have encountered a fatal error and shut down. | 101 // Whether we have encountered a fatal error and shut down. |
104 bool shut_down_; | 102 bool shut_down_; |
105 | 103 |
| 104 mojo::Binding<serial::DataSink> binding_; |
| 105 |
106 base::WeakPtrFactory<DataSinkReceiver> weak_factory_; | 106 base::WeakPtrFactory<DataSinkReceiver> weak_factory_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(DataSinkReceiver); | 108 DISALLOW_COPY_AND_ASSIGN(DataSinkReceiver); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace device | 111 } // namespace device |
112 | 112 |
113 #endif // DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ | 113 #endif // DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ |
OLD | NEW |