| 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_SERVER_H_ | 5 #ifndef NET_CURVECP_TEST_SERVER_H_ |
| 6 #define NET_CURVECP_TEST_SERVER_H_ | 6 #define NET_CURVECP_TEST_SERVER_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 29 matching lines...) Expand all Loading... |
| 40 CurveCPServerSocket* socket_; | 40 CurveCPServerSocket* socket_; |
| 41 int errors_; | 41 int errors_; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 | 44 |
| 45 // EchoServer does the actual server work for a connection. | 45 // EchoServer does the actual server work for a connection. |
| 46 // This object self destructs after finishing its work. | 46 // This object self destructs after finishing its work. |
| 47 class EchoServer { | 47 class EchoServer { |
| 48 public: | 48 public: |
| 49 EchoServer(); | 49 EchoServer(); |
| 50 ~EchoServer(); |
| 50 | 51 |
| 51 // Start the Echo Server | 52 // Start the Echo Server |
| 52 void Start(CurveCPServerSocket* socket); | 53 void Start(CurveCPServerSocket* socket); |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 void OnReadComplete(int result); | 56 void OnReadComplete(int result); |
| 56 void OnWriteComplete(int result); | 57 void OnWriteComplete(int result); |
| 57 | 58 |
| 58 void ReadData(); | 59 void ReadData(); |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 static const int kMaxMessage = 1024; | 62 static const int kMaxMessage = 1024; |
| 62 CurveCPServerSocket* socket_; | 63 CurveCPServerSocket* socket_; |
| 63 scoped_refptr<IOBuffer> read_buffer_; | 64 scoped_refptr<IOBuffer> read_buffer_; |
| 64 scoped_refptr<DrainableIOBuffer> write_buffer_; | 65 scoped_refptr<DrainableIOBuffer> write_buffer_; |
| 65 TestDataStream received_stream_; | 66 TestDataStream received_stream_; |
| 66 int bytes_received_; | 67 int bytes_received_; |
| 67 CompletionCallbackImpl<EchoServer> read_callback_; | 68 CompletionCallbackImpl<EchoServer> read_callback_; |
| 68 CompletionCallbackImpl<EchoServer> write_callback_; | 69 CompletionCallbackImpl<EchoServer> write_callback_; |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 } // namespace net | 72 } // namespace net |
| 72 | 73 |
| 73 #endif // NET_CURVECP_TEST_SERVER_H_ | 74 #endif // NET_CURVECP_TEST_SERVER_H_ |
| OLD | NEW |