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_SENDER_H_ | 5 #ifndef DEVICE_SERIAL_DATA_SENDER_H_ |
6 #define DEVICE_SERIAL_DATA_SENDER_H_ | 6 #define DEVICE_SERIAL_DATA_SENDER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const SendErrorCallback& error_callback); | 46 const SendErrorCallback& error_callback); |
47 | 47 |
48 // Requests the cancellation of any in-progress sends. Calls to Send() will | 48 // Requests the cancellation of any in-progress sends. Calls to Send() will |
49 // fail until |callback| is called. | 49 // fail until |callback| is called. |
50 bool Cancel(int32_t error, const CancelCallback& callback); | 50 bool Cancel(int32_t error, const CancelCallback& callback); |
51 | 51 |
52 private: | 52 private: |
53 class PendingSend; | 53 class PendingSend; |
54 | 54 |
55 // serial::DataSinkClient overrides. | 55 // serial::DataSinkClient overrides. |
56 virtual void ReportBytesSent(uint32_t bytes_sent) OVERRIDE; | 56 virtual void ReportBytesSent(uint32_t bytes_sent) override; |
57 virtual void ReportBytesSentAndError( | 57 virtual void ReportBytesSentAndError( |
58 uint32_t bytes_sent, | 58 uint32_t bytes_sent, |
59 int32_t error, | 59 int32_t error, |
60 const mojo::Callback<void(uint32_t)>& callback) OVERRIDE; | 60 const mojo::Callback<void(uint32_t)>& callback) override; |
61 | 61 |
62 // mojo::ErrorHandler override. | 62 // mojo::ErrorHandler override. |
63 virtual void OnConnectionError() OVERRIDE; | 63 virtual void OnConnectionError() override; |
64 | 64 |
65 // Copies data from |pending_sends_| into the data pipe and starts |waiter_| | 65 // Copies data from |pending_sends_| into the data pipe and starts |waiter_| |
66 // waiting if the pipe is full. When a PendingSend in |pending_sends_| has | 66 // waiting if the pipe is full. When a PendingSend in |pending_sends_| has |
67 // been fully copied into the data pipe, it moves to |sends_awaiting_ack_|. | 67 // been fully copied into the data pipe, it moves to |sends_awaiting_ack_|. |
68 void SendInternal(); | 68 void SendInternal(); |
69 | 69 |
70 // Invoked when |handle_| is ready for writes. Calls SendInternal(). | 70 // Invoked when |handle_| is ready for writes. Calls SendInternal(). |
71 void OnDoneWaiting(MojoResult result); | 71 void OnDoneWaiting(MojoResult result); |
72 | 72 |
73 // Dispatches a cancel callback if one is pending. | 73 // Dispatches a cancel callback if one is pending. |
(...skipping 29 matching lines...) Expand all Loading... |
103 | 103 |
104 // Whether we have encountered a fatal error and shut down. | 104 // Whether we have encountered a fatal error and shut down. |
105 bool shut_down_; | 105 bool shut_down_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(DataSender); | 107 DISALLOW_COPY_AND_ASSIGN(DataSender); |
108 }; | 108 }; |
109 | 109 |
110 } // namespace device | 110 } // namespace device |
111 | 111 |
112 #endif // DEVICE_SERIAL_DATA_SENDER_H_ | 112 #endif // DEVICE_SERIAL_DATA_SENDER_H_ |
OLD | NEW |