| 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 #include "net/curvecp/test_server.h" | 5 #include "net/curvecp/test_server.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 EchoServer::EchoServer() | 64 EchoServer::EchoServer() |
| 65 : socket_(NULL), | 65 : socket_(NULL), |
| 66 bytes_received_(0), | 66 bytes_received_(0), |
| 67 ALLOW_THIS_IN_INITIALIZER_LIST( | 67 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 68 read_callback_(this, &EchoServer::OnReadComplete)), | 68 read_callback_(this, &EchoServer::OnReadComplete)), |
| 69 ALLOW_THIS_IN_INITIALIZER_LIST( | 69 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 70 write_callback_(this, &EchoServer::OnWriteComplete)) { | 70 write_callback_(this, &EchoServer::OnWriteComplete)) { |
| 71 } | 71 } |
| 72 | 72 |
| 73 EchoServer::~EchoServer() { |
| 74 } |
| 75 |
| 73 void EchoServer::Start(CurveCPServerSocket* socket) { | 76 void EchoServer::Start(CurveCPServerSocket* socket) { |
| 74 DCHECK(!socket_); | 77 DCHECK(!socket_); |
| 75 socket_ = socket; | 78 socket_ = socket; |
| 76 | 79 |
| 77 ReadData(); | 80 ReadData(); |
| 78 // Note: |this| could be deleted here. | 81 // Note: |this| could be deleted here. |
| 79 } | 82 } |
| 80 | 83 |
| 81 void EchoServer::OnReadComplete(int result) { | 84 void EchoServer::OnReadComplete(int result) { |
| 82 LOG(INFO) << "Read complete: " << result; | 85 LOG(INFO) << "Read complete: " << result; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 int rv; | 135 int rv; |
| 133 do { | 136 do { |
| 134 rv = socket_->Read(read_buffer_, kMaxMessage, &read_callback_); | 137 rv = socket_->Read(read_buffer_, kMaxMessage, &read_callback_); |
| 135 if (rv == ERR_IO_PENDING) | 138 if (rv == ERR_IO_PENDING) |
| 136 return; | 139 return; |
| 137 OnReadComplete(rv); // Complete the read manually | 140 OnReadComplete(rv); // Complete the read manually |
| 138 } while (rv > 0); | 141 } while (rv > 0); |
| 139 } | 142 } |
| 140 | 143 |
| 141 } // namespace net | 144 } // namespace net |
| OLD | NEW |