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 <fcntl.h> | 8 #include <fcntl.h> |
9 #include <limits.h> | 9 #include <limits.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 } | 89 } |
90 #endif | 90 #endif |
91 | 91 |
92 // Copy the handles out for successful return. | 92 // Copy the handles out for successful return. |
93 socket_a->handle_ = handles[0]; | 93 socket_a->handle_ = handles[0]; |
94 socket_b->handle_ = handles[1]; | 94 socket_b->handle_ = handles[1]; |
95 | 95 |
96 return true; | 96 return true; |
97 } | 97 } |
98 | 98 |
99 // static | |
100 SyncSocket::Handle SyncSocket::UnwrapHandle( | |
101 const SyncSocket::TransitDescriptor& descriptor) { | |
102 return (SyncSocket::Handle)descriptor.fd; | |
tommi (sloooow) - chröme
2014/09/04 11:34:10
use C++ style casts
burnik
2014/09/06 18:17:09
Done. And casting removed.
| |
103 } | |
104 | |
105 bool SyncSocket::PrepareTransitDescriptor( | |
106 ProcessHandle peer_process_handle, | |
107 SyncSocket::TransitDescriptor* descriptor) { | |
108 // |TransitDescriptor| on POSIX is a |FileDescriptor|. | |
henrika (OOO until Aug 14)
2014/09/02 07:46:06
Not clear what this comment provides. The type Fil
burnik
2014/09/02 10:02:54
TransitDescriptor is a platform dependent type.
ty
henrika (OOO until Aug 14)
2014/09/02 10:26:38
It does look odd to emphasize a member which is no
burnik
2014/09/02 15:01:34
Suggestions?
On 2014/09/02 10:26:38, henrika wrote
tommi (sloooow) - chröme
2014/09/04 11:34:10
Perhaps it would be more explicit to simply say he
burnik
2014/09/06 18:17:09
I've removed this comment alltogether.
On 2014/09/
| |
109 descriptor->fd = handle(); | |
110 descriptor->auto_close = false; | |
henrika (OOO until Aug 14)
2014/09/02 07:46:06
Is this a new behavior or was it false before as w
burnik
2014/09/02 10:02:54
In all uses it was done this way.
See lefts on:
-
| |
111 return (descriptor->fd != -1); | |
tommi (sloooow) - chröme
2014/09/04 11:34:10
nit: no need for ()
burnik
2014/09/06 18:17:09
Done.
| |
112 } | |
113 | |
99 bool SyncSocket::Close() { | 114 bool SyncSocket::Close() { |
100 const bool retval = CloseHandle(handle_); | 115 const bool retval = CloseHandle(handle_); |
101 handle_ = kInvalidHandle; | 116 handle_ = kInvalidHandle; |
102 return retval; | 117 return retval; |
103 } | 118 } |
104 | 119 |
105 size_t SyncSocket::Send(const void* buffer, size_t length) { | 120 size_t SyncSocket::Send(const void* buffer, size_t length) { |
106 ThreadRestrictions::AssertIOAllowed(); | 121 ThreadRestrictions::AssertIOAllowed(); |
107 return SendHelper(handle_, buffer, length); | 122 return SendHelper(handle_, buffer, length); |
108 } | 123 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 return len; | 238 return len; |
224 } | 239 } |
225 | 240 |
226 // static | 241 // static |
227 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 242 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
228 CancelableSyncSocket* socket_b) { | 243 CancelableSyncSocket* socket_b) { |
229 return SyncSocket::CreatePair(socket_a, socket_b); | 244 return SyncSocket::CreatePair(socket_a, socket_b); |
230 } | 245 } |
231 | 246 |
232 } // namespace base | 247 } // namespace base |
OLD | NEW |