| 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_TEST_CLIENT_H_ | 5 #ifndef NET_CURVECP_TEST_CLIENT_H_ |
| 6 #define NET_CURVECP_TEST_CLIENT_H_ | 6 #define NET_CURVECP_TEST_CLIENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 virtual ~TestClient(); | 28 virtual ~TestClient(); |
| 29 | 29 |
| 30 // Starts the client, connecting to |server|. | 30 // Starts the client, connecting to |server|. |
| 31 // Client will send |bytes_to_send| bytes from the verifiable stream. | 31 // Client will send |bytes_to_send| bytes from the verifiable stream. |
| 32 // When the client has received all echoed bytes from the server, or | 32 // When the client has received all echoed bytes from the server, or |
| 33 // when an error occurs causing the client to stop, |callback| will be | 33 // when an error occurs causing the client to stop, |callback| will be |
| 34 // called with a net status code. | 34 // called with a net status code. |
| 35 // Returns true if successful in starting the client. | 35 // Returns true if successful in starting the client. |
| 36 bool Start(const HostPortPair& server, | 36 bool Start(const HostPortPair& server, |
| 37 int bytes_to_send, | 37 int bytes_to_send, |
| 38 OldCompletionCallback* callback); | 38 const CompletionCallback& callback); |
| 39 | 39 |
| 40 // Returns the number of errors this server encountered. | 40 // Returns the number of errors this server encountered. |
| 41 int error_count() { return errors_; } | 41 int error_count() { return errors_; } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 static const int kMaxMessage = 1024; | 44 static const int kMaxMessage = 1024; |
| 45 | 45 |
| 46 void OnConnectComplete(int result); | 46 void OnConnectComplete(int result); |
| 47 void OnReadComplete(int result); | 47 void OnReadComplete(int result); |
| 48 void OnWriteComplete(int result); | 48 void OnWriteComplete(int result); |
| 49 | 49 |
| 50 void ReadData(); | 50 void ReadData(); |
| 51 void SendData(); | 51 void SendData(); |
| 52 void Finish(int result); | 52 void Finish(int result); |
| 53 | 53 |
| 54 CurveCPClientSocket* socket_; | 54 CurveCPClientSocket* socket_; |
| 55 scoped_refptr<IOBuffer> read_buffer_; | 55 scoped_refptr<IOBuffer> read_buffer_; |
| 56 scoped_refptr<DrainableIOBuffer> write_buffer_; | 56 scoped_refptr<DrainableIOBuffer> write_buffer_; |
| 57 int errors_; | 57 int errors_; |
| 58 int bytes_to_read_; | 58 int bytes_to_read_; |
| 59 int bytes_to_send_; | 59 int bytes_to_send_; |
| 60 TestDataStream sent_stream_; | 60 TestDataStream sent_stream_; |
| 61 TestDataStream received_stream_; | 61 TestDataStream received_stream_; |
| 62 OldCompletionCallbackImpl<TestClient> connect_callback_; | 62 CompletionCallback finished_callback_; |
| 63 OldCompletionCallbackImpl<TestClient> read_callback_; | |
| 64 OldCompletionCallbackImpl<TestClient> write_callback_; | |
| 65 OldCompletionCallback* finished_callback_; | |
| 66 }; | 63 }; |
| 67 | 64 |
| 68 } // namespace net | 65 } // namespace net |
| 69 | 66 |
| 70 #endif // NET_CURVECP_TEST_CLIENT_H_ | 67 #endif // NET_CURVECP_TEST_CLIENT_H_ |
| OLD | NEW |