| 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_CLIENT_PACKETIZER_H_ | 5 #ifndef NET_CURVECP_CLIENT_PACKETIZER_H_ |
| 6 #define NET_CURVECP_CLIENT_PACKETIZER_H_ | 6 #define NET_CURVECP_CLIENT_PACKETIZER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class UDPClientSocket; | 23 class UDPClientSocket; |
| 24 | 24 |
| 25 class ClientPacketizer : public Packetizer { | 25 class ClientPacketizer : public Packetizer { |
| 26 public: | 26 public: |
| 27 ClientPacketizer(); | 27 ClientPacketizer(); |
| 28 virtual ~ClientPacketizer(); | 28 virtual ~ClientPacketizer(); |
| 29 | 29 |
| 30 int Connect(const AddressList& server, | 30 int Connect(const AddressList& server, |
| 31 Packetizer::Listener* listener, | 31 Packetizer::Listener* listener, |
| 32 OldCompletionCallback* callback); | 32 OldCompletionCallback* callback); |
| 33 int Connect(const AddressList& server, |
| 34 Packetizer::Listener* listener, |
| 35 const CompletionCallback& callback); |
| 33 | 36 |
| 34 // Packetizer methods | 37 // Packetizer implementation. |
| 35 virtual int SendMessage(ConnectionKey key, | 38 virtual int SendMessage(ConnectionKey key, |
| 36 const char* data, | 39 const char* data, |
| 37 size_t length, | 40 size_t length, |
| 38 OldCompletionCallback* callback) OVERRIDE; | 41 OldCompletionCallback* callback) OVERRIDE; |
| 39 virtual void Close(ConnectionKey key) OVERRIDE; | 42 virtual void Close(ConnectionKey key) OVERRIDE; |
| 40 virtual int GetPeerAddress(IPEndPoint* endpoint) const OVERRIDE; | 43 virtual int GetPeerAddress(IPEndPoint* endpoint) const OVERRIDE; |
| 41 virtual int max_message_payload() const OVERRIDE; | 44 virtual int max_message_payload() const OVERRIDE; |
| 42 | 45 |
| 43 private: | 46 private: |
| 44 enum StateType { | 47 enum StateType { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 79 |
| 77 // Read packets until an error occurs. | 80 // Read packets until an error occurs. |
| 78 int ReadPackets(); | 81 int ReadPackets(); |
| 79 | 82 |
| 80 // Callback when an internal IO is completed. | 83 // Callback when an internal IO is completed. |
| 81 void OnIOComplete(int result); | 84 void OnIOComplete(int result); |
| 82 | 85 |
| 83 StateType next_state_; | 86 StateType next_state_; |
| 84 scoped_ptr<UDPClientSocket> socket_; | 87 scoped_ptr<UDPClientSocket> socket_; |
| 85 Packetizer::Listener* listener_; | 88 Packetizer::Listener* listener_; |
| 86 OldCompletionCallback* user_callback_; | 89 OldCompletionCallback* old_user_callback_; |
| 90 CompletionCallback user_callback_; |
| 87 AddressList addresses_; | 91 AddressList addresses_; |
| 88 const struct addrinfo* current_address_; | 92 const struct addrinfo* current_address_; |
| 89 int hello_attempts_; // Number of attempts to send a Hello Packet. | 93 int hello_attempts_; // Number of attempts to send a Hello Packet. |
| 90 bool initiate_sent_; // Indicates whether the Initialte Packet was sent. | 94 bool initiate_sent_; // Indicates whether the Initiate Packet was sent. |
| 91 | 95 |
| 92 scoped_refptr<IOBuffer> read_buffer_; // Buffer for interal reads. | 96 scoped_refptr<IOBuffer> read_buffer_; // Buffer for internal reads. |
| 93 | 97 |
| 94 uchar shortterm_public_key_[32]; | 98 uchar shortterm_public_key_[32]; |
| 95 | 99 |
| 96 OldCompletionCallbackImpl<ClientPacketizer> io_callback_; | 100 OldCompletionCallbackImpl<ClientPacketizer> io_callback_; |
| 97 base::WeakPtrFactory<ClientPacketizer> weak_factory_; | 101 base::WeakPtrFactory<ClientPacketizer> weak_factory_; |
| 98 | 102 |
| 99 DISALLOW_COPY_AND_ASSIGN(ClientPacketizer); | 103 DISALLOW_COPY_AND_ASSIGN(ClientPacketizer); |
| 100 }; | 104 }; |
| 101 | 105 |
| 102 } // namespace net | 106 } // namespace net |
| 103 | 107 |
| 104 #endif // NET_CURVECP_CLIENT_PACKETIZER_H_ | 108 #endif // NET_CURVECP_CLIENT_PACKETIZER_H_ |
| OLD | NEW |