[M108 Migration][VD] Support set time and time zone offset
[platform/framework/web/chromium-efl.git] / base / sync_socket_nacl.cc
1 // Copyright 2012 The Chromium Authors
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 "base/sync_socket.h"
6
7 #include <errno.h>
8 #include <limits.h>
9 #include <stddef.h>
10 #include <stdio.h>
11 #include <sys/types.h>
12
13 #include "base/notreached.h"
14
15 namespace base {
16
17 // static
18 bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) {
19   return false;
20 }
21
22 void SyncSocket::Close() {
23   handle_.reset();
24 }
25
26 size_t SyncSocket::Send(const void* buffer, size_t length) {
27   const ssize_t bytes_written = write(handle(), buffer, length);
28   return bytes_written > 0 ? static_cast<size_t>(bytes_written) : 0;
29 }
30
31 size_t SyncSocket::Receive(void* buffer, size_t length) {
32   const ssize_t bytes_read = read(handle(), buffer, length);
33   return bytes_read > 0 ? static_cast<size_t>(bytes_read) : 0;
34 }
35
36 size_t SyncSocket::ReceiveWithTimeout(void* buffer, size_t length, TimeDelta) {
37   NOTIMPLEMENTED();
38   return 0;
39 }
40
41 size_t SyncSocket::Peek() {
42   NOTIMPLEMENTED();
43   return 0;
44 }
45
46 bool SyncSocket::IsValid() const {
47   return handle_.is_valid();
48 }
49
50 SyncSocket::Handle SyncSocket::handle() const {
51   return handle_.get();
52 }
53
54 SyncSocket::Handle SyncSocket::Release() {
55   return handle_.release();
56 }
57
58 size_t CancelableSyncSocket::Send(const void* buffer, size_t length) {
59   return SyncSocket::Send(buffer, length);
60 }
61
62 bool CancelableSyncSocket::Shutdown() {
63   Close();
64   return true;
65 }
66
67 // static
68 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
69                                       CancelableSyncSocket* socket_b) {
70   return SyncSocket::CreatePair(socket_a, socket_b);
71 }
72
73 }  // namespace base