| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |
| 6 #define BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | 6 #define BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const std::unique_ptr<BlimpMessage> message; | 64 const std::unique_ptr<BlimpMessage> message; |
| 65 const net::CompletionCallback callback; | 65 const net::CompletionCallback callback; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 typedef std::list<std::unique_ptr<BufferEntry>> MessageBuffer; | 68 typedef std::list<std::unique_ptr<BufferEntry>> MessageBuffer; |
| 69 | 69 |
| 70 // Writes the next message in the buffer if an output processor is attached | 70 // Writes the next message in the buffer if an output processor is attached |
| 71 // and the buffer contains a message. | 71 // and the buffer contains a message. |
| 72 void WriteNextMessageIfReady(); | 72 void WriteNextMessageIfReady(); |
| 73 | 73 |
| 74 // Receives the completion status of a write operation. | 74 // Called after a successful write. |
| 75 void OnWriteComplete(int result); | 75 void OnWriteComplete(int result); |
| 76 | 76 |
| 77 BlimpMessageProcessor* output_processor_ = nullptr; | 77 BlimpMessageProcessor* output_processor_ = nullptr; |
| 78 net::CancelableCompletionCallback write_complete_cb_; | 78 net::CancelableCompletionCallback write_complete_cb_; |
| 79 | 79 |
| 80 // Maximum serialized footprint of buffered messages. | 80 // Maximum serialized footprint of buffered messages. |
| 81 int max_buffer_size_bytes_; | 81 int max_buffer_size_bytes_; |
| 82 | 82 |
| 83 // Serialized footprint of the messages contained in the write and ack | 83 // Serialized footprint of the messages contained in the write and ack |
| 84 // buffers. | 84 // buffers. |
| 85 int current_buffer_size_bytes_ = 0; | 85 int current_buffer_size_bytes_ = 0; |
| 86 | 86 |
| 87 // The ID used by the last outgoing message. | 87 // The ID used by the last outgoing message. |
| 88 int64_t prev_message_id_ = 0; | 88 int64_t prev_message_id_ = 0; |
| 89 | 89 |
| 90 // List of unsent messages. | 90 // List of unsent messages. |
| 91 MessageBuffer write_buffer_; | 91 MessageBuffer write_buffer_; |
| 92 | 92 |
| 93 // List of messages that are sent and awaiting acknowledgment. | 93 // List of messages that are sent and awaiting acknowledgment. |
| 94 // The messages in |ack_buffer_| are contiguous with the messages in | 94 // The messages in |ack_buffer_| are contiguous with the messages in |
| 95 // |write_buffer_|. | 95 // |write_buffer_|. |
| 96 MessageBuffer ack_buffer_; | 96 MessageBuffer ack_buffer_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer); | 98 DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace blimp | 101 } // namespace blimp |
| 102 | 102 |
| 103 #endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | 103 #endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |
| OLD | NEW |