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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 DPLOG(ERROR) << "Cannot duplicate socket handle for peer process."; | 228 DPLOG(ERROR) << "Cannot duplicate socket handle for peer process."; |
229 return false; | 229 return false; |
230 } | 230 } |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 bool SyncSocket::Close() { | 234 bool SyncSocket::Close() { |
235 if (handle_ == kInvalidHandle) | 235 if (handle_ == kInvalidHandle) |
236 return true; | 236 return true; |
237 | 237 |
238 const BOOL result = ::CloseHandle(handle_); | 238 const BOOL result = CloseHandle(handle_); |
239 CHECK(result); | |
240 handle_ = kInvalidHandle; | 239 handle_ = kInvalidHandle; |
241 return result == TRUE; | 240 return result == TRUE; |
242 } | 241 } |
243 | 242 |
244 size_t SyncSocket::Send(const void* buffer, size_t length) { | 243 size_t SyncSocket::Send(const void* buffer, size_t length) { |
245 ThreadRestrictions::AssertIOAllowed(); | 244 ThreadRestrictions::AssertIOAllowed(); |
246 DCHECK_GT(length, 0u); | 245 DCHECK_GT(length, 0u); |
247 DCHECK_LE(length, kMaxMessageLength); | 246 DCHECK_LE(length, kMaxMessageLength); |
248 DCHECK_NE(handle_, kInvalidHandle); | 247 DCHECK_NE(handle_, kInvalidHandle); |
249 size_t count = 0; | 248 size_t count = 0; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 static_cast<DWORD>(timeout.InMilliseconds())); | 333 static_cast<DWORD>(timeout.InMilliseconds())); |
335 } | 334 } |
336 | 335 |
337 // static | 336 // static |
338 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
339 CancelableSyncSocket* socket_b) { | 338 CancelableSyncSocket* socket_b) { |
340 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); | 339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); |
341 } | 340 } |
342 | 341 |
343 } // namespace base | 342 } // namespace base |
OLD | NEW |