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 16 matching lines...) Expand all Loading... |
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); | 36 int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); |
| 37 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
37 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); | 38 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); |
38 | 39 |
39 // Packetizer::Listener methods: | 40 // Packetizer::Listener implementation. |
40 virtual void OnConnection(ConnectionKey key) OVERRIDE; | 41 virtual void OnConnection(ConnectionKey key) OVERRIDE; |
41 virtual void OnClose(Packetizer* packetizer, ConnectionKey key); | 42 virtual void OnClose(Packetizer* packetizer, ConnectionKey key); |
42 virtual void OnMessage(Packetizer* packetizer, | 43 virtual void OnMessage(Packetizer* packetizer, |
43 ConnectionKey key, | 44 ConnectionKey key, |
44 unsigned char* msg, | 45 unsigned char* msg, |
45 size_t length) OVERRIDE; | 46 size_t length) OVERRIDE; |
46 | 47 |
47 protected: | 48 protected: |
48 ConnectionKey key_; | 49 ConnectionKey key_; |
49 | 50 |
(...skipping 19 matching lines...) Expand all Loading... |
69 | 70 |
70 // The send_buffer is a list of pending data to pack into messages and send | 71 // The send_buffer is a list of pending data to pack into messages and send |
71 // to the remote. | 72 // to the remote. |
72 CircularBuffer send_buffer_; | 73 CircularBuffer send_buffer_; |
73 OldCompletionCallback* send_complete_callback_; | 74 OldCompletionCallback* send_complete_callback_; |
74 scoped_refptr<IOBuffer> pending_send_; | 75 scoped_refptr<IOBuffer> pending_send_; |
75 int pending_send_length_; | 76 int pending_send_length_; |
76 | 77 |
77 // The read_buffer is a list of pending data which has been unpacked from | 78 // The read_buffer is a list of pending data which has been unpacked from |
78 // messages and is awaiting delivery to the application. | 79 // messages and is awaiting delivery to the application. |
79 OldCompletionCallback* receive_complete_callback_; | 80 OldCompletionCallback* old_receive_complete_callback_; |
| 81 CompletionCallback receive_complete_callback_; |
80 scoped_refptr<IOBuffer> pending_receive_; | 82 scoped_refptr<IOBuffer> pending_receive_; |
81 int pending_receive_length_; | 83 int pending_receive_length_; |
82 | 84 |
83 // The list of received but unprocessed messages. | 85 // The list of received but unprocessed messages. |
84 std::list<scoped_refptr<IOBufferWithSize> > read_queue_; | 86 std::list<scoped_refptr<IOBufferWithSize> > read_queue_; |
85 | 87 |
86 ReceivedBlockList received_list_; | 88 ReceivedBlockList received_list_; |
87 SentBlockList sent_list_; | 89 SentBlockList sent_list_; |
88 bool send_message_in_progress_; | 90 bool send_message_in_progress_; |
89 | 91 |
90 // A timer to fire when a timeout has occurred. | 92 // A timer to fire when a timeout has occurred. |
91 base::OneShotTimer<Messenger> send_timeout_timer_; | 93 base::OneShotTimer<Messenger> send_timeout_timer_; |
92 // A timer to fire when we can send data. | 94 // A timer to fire when we can send data. |
93 base::OneShotTimer<Messenger> send_timer_; | 95 base::OneShotTimer<Messenger> send_timer_; |
94 | 96 |
95 OldCompletionCallbackImpl<Messenger> send_message_callback_; | 97 OldCompletionCallbackImpl<Messenger> send_message_callback_; |
96 | 98 |
97 ScopedRunnableMethodFactory<Messenger> factory_; | 99 ScopedRunnableMethodFactory<Messenger> factory_; |
98 DISALLOW_COPY_AND_ASSIGN(Messenger); | 100 DISALLOW_COPY_AND_ASSIGN(Messenger); |
99 }; | 101 }; |
100 | 102 |
101 } // namespace net | 103 } // namespace net |
102 | 104 |
103 #endif // NET_CURVECP_MESSENGER_H_ | 105 #endif // NET_CURVECP_MESSENGER_H_ |
OLD | NEW |