OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/sync_socket.h" | 5 #include "base/sync_socket.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 20 matching lines...) Expand all Loading... | |
31 if (handle_ != kInvalidHandle) { | 31 if (handle_ != kInvalidHandle) { |
32 if (close(handle_) < 0) | 32 if (close(handle_) < 0) |
33 DPLOG(ERROR) << "close"; | 33 DPLOG(ERROR) << "close"; |
34 handle_ = -1; | 34 handle_ = -1; |
35 } | 35 } |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
39 size_t SyncSocket::Send(const void* buffer, size_t length) { | 39 size_t SyncSocket::Send(const void* buffer, size_t length) { |
40 // Not implemented since it's not needed by any client code yet. | 40 // Not implemented since it's not needed by any client code yet. |
41 return -1; | 41 NOTIMPLEMENTED(); |
42 return 0; | |
42 } | 43 } |
43 | 44 |
44 size_t SyncSocket::Receive(void* buffer, size_t length) { | 45 size_t SyncSocket::Receive(void* buffer, size_t length) { |
45 return read(handle_, buffer, length); | 46 return read(handle_, buffer, length); |
46 } | 47 } |
47 | 48 |
49 size_t SyncSocket::ReceiveWithTimeout(void* buffer, size_t length, TimeDelta) { | |
50 NOTIMPLEMENTED(); | |
51 return 0; | |
jar (doing other things)
2013/10/14 22:49:18
When I argued for returning 0 (not -1), I was more
DaleCurtis
2013/10/14 23:12:33
Only Receive(), Shutdown() are currently called by
| |
52 } | |
53 | |
48 size_t SyncSocket::Peek() { | 54 size_t SyncSocket::Peek() { |
49 return -1; | 55 NOTIMPLEMENTED(); |
56 return 0; | |
50 } | 57 } |
51 | 58 |
52 CancelableSyncSocket::CancelableSyncSocket() { | 59 CancelableSyncSocket::CancelableSyncSocket() { |
53 } | 60 } |
54 | 61 |
55 CancelableSyncSocket::CancelableSyncSocket(Handle handle) | 62 CancelableSyncSocket::CancelableSyncSocket(Handle handle) |
56 : SyncSocket(handle) { | 63 : SyncSocket(handle) { |
57 } | 64 } |
58 | 65 |
59 size_t CancelableSyncSocket::Send(const void* buffer, size_t length) { | 66 size_t CancelableSyncSocket::Send(const void* buffer, size_t length) { |
60 return -1; | 67 NOTIMPLEMENTED(); |
68 return 0; | |
61 } | 69 } |
62 | 70 |
63 bool CancelableSyncSocket::Shutdown() { | 71 bool CancelableSyncSocket::Shutdown() { |
64 return false; | 72 return false; |
65 } | 73 } |
66 | 74 |
67 // static | 75 // static |
68 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 76 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
69 CancelableSyncSocket* socket_b) { | 77 CancelableSyncSocket* socket_b) { |
70 return SyncSocket::CreatePair(socket_a, socket_b); | 78 return SyncSocket::CreatePair(socket_a, socket_b); |
71 } | 79 } |
72 | 80 |
73 } // namespace base | 81 } // namespace base |
OLD | NEW |