| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 NET_CURVECP_MESSENGER_H_ | 5 #ifndef NET_CURVECP_MESSENGER_H_ |
| 6 #define NET_CURVECP_MESSENGER_H_ | 6 #define NET_CURVECP_MESSENGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class IOBufferWithSize; | 26 class IOBufferWithSize; |
| 27 class Packetizer; | 27 class Packetizer; |
| 28 | 28 |
| 29 // The messenger provides the reliable CurveCP transport. | 29 // The messenger provides the reliable CurveCP transport. |
| 30 class Messenger : public base::NonThreadSafe, | 30 class Messenger : public base::NonThreadSafe, |
| 31 public Packetizer::Listener { | 31 public Packetizer::Listener { |
| 32 public: | 32 public: |
| 33 explicit Messenger(Packetizer* packetizer); | 33 explicit Messenger(Packetizer* packetizer); |
| 34 virtual ~Messenger(); | 34 virtual ~Messenger(); |
| 35 | 35 |
| 36 int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); | |
| 37 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 36 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
| 38 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); | 37 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
| 39 | 38 |
| 40 // Packetizer::Listener implementation. | 39 // Packetizer::Listener implementation. |
| 41 virtual void OnConnection(ConnectionKey key) OVERRIDE; | 40 virtual void OnConnection(ConnectionKey key) OVERRIDE; |
| 42 virtual void OnClose(Packetizer* packetizer, ConnectionKey key); | 41 virtual void OnClose(Packetizer* packetizer, ConnectionKey key); |
| 43 virtual void OnMessage(Packetizer* packetizer, | 42 virtual void OnMessage(Packetizer* packetizer, |
| 44 ConnectionKey key, | 43 ConnectionKey key, |
| 45 unsigned char* msg, | 44 unsigned char* msg, |
| 46 size_t length) OVERRIDE; | 45 size_t length) OVERRIDE; |
| 47 | 46 |
| 48 protected: | 47 protected: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 void SendMessage(int64 position); | 63 void SendMessage(int64 position); |
| 65 void RecvMessage(); | 64 void RecvMessage(); |
| 66 void SendAck(uint32 last_message_received); | 65 void SendAck(uint32 last_message_received); |
| 67 | 66 |
| 68 RttAndSendRateCalculator rtt_; | 67 RttAndSendRateCalculator rtt_; |
| 69 Packetizer* packetizer_; | 68 Packetizer* packetizer_; |
| 70 | 69 |
| 71 // The send_buffer is a list of pending data to pack into messages and send | 70 // The send_buffer is a list of pending data to pack into messages and send |
| 72 // to the remote. | 71 // to the remote. |
| 73 CircularBuffer send_buffer_; | 72 CircularBuffer send_buffer_; |
| 74 OldCompletionCallback* send_complete_callback_; | 73 CompletionCallback send_complete_callback_; |
| 75 scoped_refptr<IOBuffer> pending_send_; | 74 scoped_refptr<IOBuffer> pending_send_; |
| 76 int pending_send_length_; | 75 int pending_send_length_; |
| 77 | 76 |
| 78 // The read_buffer is a list of pending data which has been unpacked from | 77 // The read_buffer is a list of pending data which has been unpacked from |
| 79 // messages and is awaiting delivery to the application. | 78 // messages and is awaiting delivery to the application. |
| 80 OldCompletionCallback* old_receive_complete_callback_; | |
| 81 CompletionCallback receive_complete_callback_; | 79 CompletionCallback receive_complete_callback_; |
| 82 scoped_refptr<IOBuffer> pending_receive_; | 80 scoped_refptr<IOBuffer> pending_receive_; |
| 83 int pending_receive_length_; | 81 int pending_receive_length_; |
| 84 | 82 |
| 85 // The list of received but unprocessed messages. | 83 // The list of received but unprocessed messages. |
| 86 std::list<scoped_refptr<IOBufferWithSize> > read_queue_; | 84 std::list<scoped_refptr<IOBufferWithSize> > read_queue_; |
| 87 | 85 |
| 88 ReceivedBlockList received_list_; | 86 ReceivedBlockList received_list_; |
| 89 SentBlockList sent_list_; | 87 SentBlockList sent_list_; |
| 90 bool send_message_in_progress_; | 88 bool send_message_in_progress_; |
| 91 | 89 |
| 92 // A timer to fire when a timeout has occurred. | 90 // A timer to fire when a timeout has occurred. |
| 93 base::OneShotTimer<Messenger> send_timeout_timer_; | 91 base::OneShotTimer<Messenger> send_timeout_timer_; |
| 94 // A timer to fire when we can send data. | 92 // A timer to fire when we can send data. |
| 95 base::OneShotTimer<Messenger> send_timer_; | 93 base::OneShotTimer<Messenger> send_timer_; |
| 96 | 94 |
| 97 OldCompletionCallbackImpl<Messenger> send_message_callback_; | |
| 98 | |
| 99 ScopedRunnableMethodFactory<Messenger> factory_; | |
| 100 DISALLOW_COPY_AND_ASSIGN(Messenger); | 95 DISALLOW_COPY_AND_ASSIGN(Messenger); |
| 101 }; | 96 }; |
| 102 | 97 |
| 103 } // namespace net | 98 } // namespace net |
| 104 | 99 |
| 105 #endif // NET_CURVECP_MESSENGER_H_ | 100 #endif // NET_CURVECP_MESSENGER_H_ |
| OLD | NEW |