| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/protocol/socket_wrapper.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "net/base/net_errors.h" | |
| 9 | |
| 10 namespace remoting { | |
| 11 namespace protocol { | |
| 12 | |
| 13 SocketWrapper::SocketWrapper(net::Socket* socket) | |
| 14 : socket_(socket) { | |
| 15 } | |
| 16 | |
| 17 SocketWrapper::~SocketWrapper() { | |
| 18 DCHECK(!socket_.get()); | |
| 19 } | |
| 20 | |
| 21 int SocketWrapper::Read(net::IOBuffer* buf, int buf_len, | |
| 22 net::CompletionCallback* callback) { | |
| 23 if (!socket_.get()) | |
| 24 return net::ERR_SOCKET_NOT_CONNECTED; | |
| 25 return socket_->Read(buf, buf_len, callback); | |
| 26 } | |
| 27 | |
| 28 int SocketWrapper::Write(net::IOBuffer* buf, int buf_len, | |
| 29 net::CompletionCallback* callback) { | |
| 30 if (!socket_.get()) | |
| 31 return net::ERR_SOCKET_NOT_CONNECTED; | |
| 32 return socket_->Write(buf, buf_len, callback); | |
| 33 } | |
| 34 | |
| 35 bool SocketWrapper::SetReceiveBufferSize(int32 size) { | |
| 36 if (!socket_.get()) | |
| 37 return false; | |
| 38 return socket_->SetReceiveBufferSize(size); | |
| 39 } | |
| 40 | |
| 41 bool SocketWrapper::SetSendBufferSize(int32 size) { | |
| 42 if (!socket_.get()) | |
| 43 return false; | |
| 44 return socket_->SetSendBufferSize(size); | |
| 45 } | |
| 46 | |
| 47 void SocketWrapper::Disconnect() { | |
| 48 socket_.reset(); | |
| 49 } | |
| 50 | |
| 51 } // namespace protocol | |
| 52 } // namespace remoting | |
| OLD | NEW |