blob: 29b2bbfb984bc92677c0fda62dc7963055a8ff16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/protocol/socket_wrapper.h"
#include "base/logging.h"
#include "net/base/net_errors.h"
namespace remoting {
namespace protocol {
SocketWrapper::SocketWrapper(net::Socket* socket)
: socket_(socket) {
}
SocketWrapper::~SocketWrapper() {
DCHECK(!socket_.get());
}
int SocketWrapper::Read(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
if (!socket_.get())
return net::ERR_SOCKET_NOT_CONNECTED;
return socket_->Read(buf, buf_len, callback);
}
int SocketWrapper::Write(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
if (!socket_.get())
return net::ERR_SOCKET_NOT_CONNECTED;
return socket_->Write(buf, buf_len, callback);
}
bool SocketWrapper::SetReceiveBufferSize(int32 size) {
if (!socket_.get())
return false;
return socket_->SetReceiveBufferSize(size);
}
bool SocketWrapper::SetSendBufferSize(int32 size) {
if (!socket_.get())
return false;
return socket_->SetSendBufferSize(size);
}
void SocketWrapper::Disconnect() {
socket_.reset();
}
} // namespace protocol
} // namespace remoting
|