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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/threading/thread_restrictions.h" | 8 #include "base/threading/thread_restrictions.h" |
9 #include "base/win/scoped_handle.h" | 9 #include "base/win/scoped_handle.h" |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 | 200 |
201 SyncSocket::~SyncSocket() { | 201 SyncSocket::~SyncSocket() { |
202 Close(); | 202 Close(); |
203 } | 203 } |
204 | 204 |
205 // static | 205 // static |
206 bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) { | 206 bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) { |
207 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, false); | 207 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, false); |
208 } | 208 } |
209 | 209 |
210 // static | |
211 SyncSocket::Handle SyncSocket::UnwrapHandle( | |
212 const TransitDescriptor& descriptor) { | |
213 return descriptor; | |
214 } | |
215 | |
216 bool SyncSocket::PrepareTransitDescriptor(ProcessHandle peer_process_handle, | |
217 TransitDescriptor* descriptor) { | |
218 DCHECK(descriptor); | |
tommi (sloooow) - chröme
2014/09/04 19:47:00
this dcheck on the other hand is useful
burnik
2014/09/05 08:17:42
Acknowledged.
| |
219 if (!::DuplicateHandle(GetCurrentProcess(), handle(), peer_process_handle, | |
220 descriptor, 0, FALSE, DUPLICATE_SAME_ACCESS)) { | |
221 DPLOG(ERROR) << "Cannot duplicate socket handle for peer process."; | |
222 return false; | |
223 } | |
224 return true; | |
225 } | |
226 | |
210 bool SyncSocket::Close() { | 227 bool SyncSocket::Close() { |
211 if (handle_ == kInvalidHandle) | 228 if (handle_ == kInvalidHandle) |
212 return true; | 229 return true; |
213 | 230 |
214 const BOOL result = CloseHandle(handle_); | 231 const BOOL result = CloseHandle(handle_); |
215 handle_ = kInvalidHandle; | 232 handle_ = kInvalidHandle; |
216 return result == TRUE; | 233 return result == TRUE; |
217 } | 234 } |
218 | 235 |
219 size_t SyncSocket::Send(const void* buffer, size_t length) { | 236 size_t SyncSocket::Send(const void* buffer, size_t length) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 &file_operation_, &shutdown_event_, this, timeout.InMilliseconds()); | 325 &file_operation_, &shutdown_event_, this, timeout.InMilliseconds()); |
309 } | 326 } |
310 | 327 |
311 // static | 328 // static |
312 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 329 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
313 CancelableSyncSocket* socket_b) { | 330 CancelableSyncSocket* socket_b) { |
314 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); | 331 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); |
315 } | 332 } |
316 | 333 |
317 } // namespace base | 334 } // namespace base |
OLD | NEW |