| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <limits.h> | 6 #include <limits.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 const size_t kPipePathMax = kPipePrefixSize + kPathMax + 1; | 21 const size_t kPipePathMax = kPipePrefixSize + kPathMax + 1; |
| 22 | 22 |
| 23 // To avoid users sending negative message lengths to Send/Receive | 23 // To avoid users sending negative message lengths to Send/Receive |
| 24 // we clamp message lengths, which are size_t, to no more than INT_MAX. | 24 // we clamp message lengths, which are size_t, to no more than INT_MAX. |
| 25 const size_t kMaxMessageLength = static_cast<size_t>(INT_MAX); | 25 const size_t kMaxMessageLength = static_cast<size_t>(INT_MAX); |
| 26 | 26 |
| 27 const int kOutBufferSize = 4096; | 27 const int kOutBufferSize = 4096; |
| 28 const int kInBufferSize = 4096; | 28 const int kInBufferSize = 4096; |
| 29 const int kDefaultTimeoutMilliSeconds = 1000; | 29 const int kDefaultTimeoutMilliSeconds = 1000; |
| 30 | 30 |
| 31 static const SyncSocket::Handle kInvalidHandle = INVALID_HANDLE_VALUE; | 31 } // namespace |
| 32 | 32 |
| 33 } // namespace | 33 const SyncSocket::Handle SyncSocket::kInvalidHandle = INVALID_HANDLE_VALUE; |
| 34 | 34 |
| 35 bool SyncSocket::CreatePair(SyncSocket* pair[2]) { | 35 bool SyncSocket::CreatePair(SyncSocket* pair[2]) { |
| 36 Handle handles[2]; | 36 Handle handles[2]; |
| 37 SyncSocket* tmp_sockets[2]; | 37 SyncSocket* tmp_sockets[2]; |
| 38 | 38 |
| 39 // Create the two SyncSocket objects first to avoid ugly cleanup issues. | 39 // Create the two SyncSocket objects first to avoid ugly cleanup issues. |
| 40 tmp_sockets[0] = new SyncSocket(kInvalidHandle); | 40 tmp_sockets[0] = new SyncSocket(kInvalidHandle); |
| 41 if (tmp_sockets[0] == NULL) { | 41 if (tmp_sockets[0] == NULL) { |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return count; | 140 return count; |
| 141 } | 141 } |
| 142 | 142 |
| 143 size_t SyncSocket::Peek() { | 143 size_t SyncSocket::Peek() { |
| 144 DWORD available = 0; | 144 DWORD available = 0; |
| 145 PeekNamedPipe(handle_, NULL, 0, NULL, &available, NULL); | 145 PeekNamedPipe(handle_, NULL, 0, NULL, &available, NULL); |
| 146 return available; | 146 return available; |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace base | 149 } // namespace base |
| OLD | NEW |