| 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> |
| 9 |
| 8 #include <list> | 10 #include <list> |
| 9 #include <queue> | 11 #include <queue> |
| 10 #include <utility> | 12 #include <utility> |
| 11 | 13 |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "blimp/net/blimp_message_checkpoint_observer.h" | 15 #include "blimp/net/blimp_message_checkpoint_observer.h" |
| 14 #include "blimp/net/blimp_message_processor.h" | 16 #include "blimp/net/blimp_message_processor.h" |
| 15 #include "blimp/net/blimp_net_export.h" | 17 #include "blimp/net/blimp_net_export.h" |
| 16 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
| 17 | 19 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 39 // Marks all messages in buffer for retransmission. | 41 // Marks all messages in buffer for retransmission. |
| 40 void RetransmitBufferedMessages(); | 42 void RetransmitBufferedMessages(); |
| 41 | 43 |
| 42 // BlimpMessageProcessor implementation. | 44 // BlimpMessageProcessor implementation. |
| 43 // |callback|, if set, will be called once the remote end has acknowledged the | 45 // |callback|, if set, will be called once the remote end has acknowledged the |
| 44 // receipt of |message|. | 46 // receipt of |message|. |
| 45 void ProcessMessage(scoped_ptr<BlimpMessage> message, | 47 void ProcessMessage(scoped_ptr<BlimpMessage> message, |
| 46 const net::CompletionCallback& callback) override; | 48 const net::CompletionCallback& callback) override; |
| 47 | 49 |
| 48 // MessageCheckpointObserver implementation. | 50 // MessageCheckpointObserver implementation. |
| 49 void OnMessageCheckpoint(int64 message_id) override; | 51 void OnMessageCheckpoint(int64_t message_id) override; |
| 50 | 52 |
| 51 int GetBufferByteSizeForTest() const; | 53 int GetBufferByteSizeForTest() const; |
| 52 int GetUnacknowledgedMessageCountForTest() const; | 54 int GetUnacknowledgedMessageCountForTest() const; |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 struct BufferEntry { | 57 struct BufferEntry { |
| 56 BufferEntry(scoped_ptr<BlimpMessage> message, | 58 BufferEntry(scoped_ptr<BlimpMessage> message, |
| 57 net::CompletionCallback callback); | 59 net::CompletionCallback callback); |
| 58 ~BufferEntry(); | 60 ~BufferEntry(); |
| 59 | 61 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 74 net::CancelableCompletionCallback write_complete_cb_; | 76 net::CancelableCompletionCallback write_complete_cb_; |
| 75 | 77 |
| 76 // Maximum serialized footprint of buffered messages. | 78 // Maximum serialized footprint of buffered messages. |
| 77 int max_buffer_size_bytes_; | 79 int max_buffer_size_bytes_; |
| 78 | 80 |
| 79 // Serialized footprint of the messages contained in the write and ack | 81 // Serialized footprint of the messages contained in the write and ack |
| 80 // buffers. | 82 // buffers. |
| 81 int current_buffer_size_bytes_ = 0; | 83 int current_buffer_size_bytes_ = 0; |
| 82 | 84 |
| 83 // The ID used by the last outgoing message. | 85 // The ID used by the last outgoing message. |
| 84 int64 prev_message_id_ = 0; | 86 int64_t prev_message_id_ = 0; |
| 85 | 87 |
| 86 // List of unsent messages. | 88 // List of unsent messages. |
| 87 MessageBuffer write_buffer_; | 89 MessageBuffer write_buffer_; |
| 88 | 90 |
| 89 // List of messages that are sent and awaiting acknowledgment. | 91 // List of messages that are sent and awaiting acknowledgment. |
| 90 // The messages in |ack_buffer_| are contiguous with the messages in | 92 // The messages in |ack_buffer_| are contiguous with the messages in |
| 91 // |write_buffer_|. | 93 // |write_buffer_|. |
| 92 MessageBuffer ack_buffer_; | 94 MessageBuffer ack_buffer_; |
| 93 | 95 |
| 94 DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer); | 96 DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer); |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 } // namespace blimp | 99 } // namespace blimp |
| 98 | 100 |
| 99 #endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | 101 #endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |
| OLD | NEW |