1 // Copyright (c) 2012 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.
5 #include "base/sync_socket.h"
10 #include <sys/types.h>
12 #include "base/logging.h"
17 const SyncSocket::Handle
SyncSocket::kInvalidHandle
= -1;
19 SyncSocket::SyncSocket() : handle_(kInvalidHandle
) {
22 SyncSocket::~SyncSocket() {
26 bool SyncSocket::CreatePair(SyncSocket
* socket_a
, SyncSocket
* socket_b
) {
30 bool SyncSocket::Close() {
31 if (handle_
!= kInvalidHandle
) {
32 if (close(handle_
) < 0)
33 DPLOG(ERROR
) << "close";
39 size_t SyncSocket::Send(const void* buffer
, size_t length
) {
40 // Not implemented since it's not needed by any client code yet.
44 size_t SyncSocket::Receive(void* buffer
, size_t length
) {
45 return read(handle_
, buffer
, length
);
48 size_t SyncSocket::Peek() {
52 CancelableSyncSocket::CancelableSyncSocket() {
55 CancelableSyncSocket::CancelableSyncSocket(Handle handle
)
56 : SyncSocket(handle
) {
59 size_t CancelableSyncSocket::Send(const void* buffer
, size_t length
) {
63 bool CancelableSyncSocket::Shutdown() {
68 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket
* socket_a
,
69 CancelableSyncSocket
* socket_b
) {
70 return SyncSocket::CreatePair(socket_a
, socket_b
);