| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106   ThreadRestrictions::AssertIOAllowed(); | 106   ThreadRestrictions::AssertIOAllowed(); | 
| 107   return SendHelper(handle_, buffer, length); | 107   return SendHelper(handle_, buffer, length); | 
| 108 } | 108 } | 
| 109 | 109 | 
| 110 size_t SyncSocket::Receive(void* buffer, size_t length) { | 110 size_t SyncSocket::Receive(void* buffer, size_t length) { | 
| 111   ThreadRestrictions::AssertIOAllowed(); | 111   ThreadRestrictions::AssertIOAllowed(); | 
| 112   DCHECK_GT(length, 0u); | 112   DCHECK_GT(length, 0u); | 
| 113   DCHECK_LE(length, kMaxMessageLength); | 113   DCHECK_LE(length, kMaxMessageLength); | 
| 114   DCHECK_NE(handle_, kInvalidHandle); | 114   DCHECK_NE(handle_, kInvalidHandle); | 
| 115   char* charbuffer = static_cast<char*>(buffer); | 115   char* charbuffer = static_cast<char*>(buffer); | 
| 116   if (file_util::ReadFromFD(handle_, charbuffer, length)) | 116   if (ReadFromFD(handle_, charbuffer, length)) | 
| 117     return length; | 117     return length; | 
| 118   return 0; | 118   return 0; | 
| 119 } | 119 } | 
| 120 | 120 | 
| 121 size_t SyncSocket::ReceiveWithTimeout(void* buffer, | 121 size_t SyncSocket::ReceiveWithTimeout(void* buffer, | 
| 122                                       size_t length, | 122                                       size_t length, | 
| 123                                       TimeDelta timeout) { | 123                                       TimeDelta timeout) { | 
| 124   ThreadRestrictions::AssertIOAllowed(); | 124   ThreadRestrictions::AssertIOAllowed(); | 
| 125   DCHECK_GT(length, 0u); | 125   DCHECK_GT(length, 0u); | 
| 126   DCHECK_LE(length, kMaxMessageLength); | 126   DCHECK_LE(length, kMaxMessageLength); | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 223   return len; | 223   return len; | 
| 224 } | 224 } | 
| 225 | 225 | 
| 226 // static | 226 // static | 
| 227 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 227 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 
| 228                                       CancelableSyncSocket* socket_b) { | 228                                       CancelableSyncSocket* socket_b) { | 
| 229   return SyncSocket::CreatePair(socket_a, socket_b); | 229   return SyncSocket::CreatePair(socket_a, socket_b); | 
| 230 } | 230 } | 
| 231 | 231 | 
| 232 }  // namespace base | 232 }  // namespace base | 
| OLD | NEW | 
|---|