Chromium Code Reviews| 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); | |
|
Lei Zhang
2015/09/22 08:03:30
Also PCHECK()
| |
| 239 handle_ = kInvalidHandle; | 240 handle_ = kInvalidHandle; |
| 240 return result == TRUE; | 241 return result == TRUE; |
| 241 } | 242 } |
| 242 | 243 |
| 243 size_t SyncSocket::Send(const void* buffer, size_t length) { | 244 size_t SyncSocket::Send(const void* buffer, size_t length) { |
| 244 ThreadRestrictions::AssertIOAllowed(); | 245 ThreadRestrictions::AssertIOAllowed(); |
| 245 DCHECK_GT(length, 0u); | 246 DCHECK_GT(length, 0u); |
| 246 DCHECK_LE(length, kMaxMessageLength); | 247 DCHECK_LE(length, kMaxMessageLength); |
| 247 DCHECK_NE(handle_, kInvalidHandle); | 248 DCHECK_NE(handle_, kInvalidHandle); |
| 248 size_t count = 0; | 249 size_t count = 0; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 static_cast<DWORD>(timeout.InMilliseconds())); | 334 static_cast<DWORD>(timeout.InMilliseconds())); |
| 334 } | 335 } |
| 335 | 336 |
| 336 // static | 337 // static |
| 337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 338 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
| 338 CancelableSyncSocket* socket_b) { | 339 CancelableSyncSocket* socket_b) { |
| 339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); | 340 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); |
| 340 } | 341 } |
| 341 | 342 |
| 342 } // namespace base | 343 } // namespace base |
| OLD | NEW |