Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 memmove(buffer_, buffer_ + read, data_len_); | 75 memmove(buffer_, buffer_ + read, data_len_); |
| 76 } | 76 } |
| 77 pv = static_cast<char *>(pv) + read; | 77 pv = static_cast<char *>(pv) + read; |
| 78 cb -= read; | 78 cb -= read; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // FIX: If cb == 0, we won't generate another read event | 81 // FIX: If cb == 0, we won't generate another read event |
| 82 | 82 |
| 83 int res = AsyncSocketAdapter::Recv(pv, cb); | 83 int res = AsyncSocketAdapter::Recv(pv, cb); |
| 84 if (res < 0) | 84 if (res < 0) |
| 85 return res; | 85 return read ? static_cast<int>(read) : res; |
| 86 | 86 |
| 87 return res + static_cast<int>(read); | 87 return res + static_cast<int>(read); |
| 88 } | 88 } |
|
pthatcher1
2015/07/15 23:42:24
I think this would be more clear as something like
| |
| 89 | 89 |
| 90 void BufferedReadAdapter::BufferInput(bool on) { | 90 void BufferedReadAdapter::BufferInput(bool on) { |
| 91 buffering_ = on; | 91 buffering_ = on; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void BufferedReadAdapter::OnReadEvent(AsyncSocket * socket) { | 94 void BufferedReadAdapter::OnReadEvent(AsyncSocket * socket) { |
| 95 ASSERT(socket == socket_); | 95 ASSERT(socket == socket_); |
| 96 | 96 |
| 97 if (!buffering_) { | 97 if (!buffering_) { |
| 98 AsyncSocketAdapter::OnReadEvent(socket); | 98 AsyncSocketAdapter::OnReadEvent(socket); |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 void LoggingSocketAdapter::OnCloseEvent(AsyncSocket * socket, int err) { | 895 void LoggingSocketAdapter::OnCloseEvent(AsyncSocket * socket, int err) { |
| 896 LogMultiline(level_, label_.c_str(), false, NULL, 0, hex_mode_, &lms_); | 896 LogMultiline(level_, label_.c_str(), false, NULL, 0, hex_mode_, &lms_); |
| 897 LogMultiline(level_, label_.c_str(), true, NULL, 0, hex_mode_, &lms_); | 897 LogMultiline(level_, label_.c_str(), true, NULL, 0, hex_mode_, &lms_); |
| 898 LOG_V(level_) << label_ << " Closed with error: " << err; | 898 LOG_V(level_) << label_ << " Closed with error: " << err; |
| 899 AsyncSocketAdapter::OnCloseEvent(socket, err); | 899 AsyncSocketAdapter::OnCloseEvent(socket, err); |
| 900 } | 900 } |
| 901 | 901 |
| 902 /////////////////////////////////////////////////////////////////////////////// | 902 /////////////////////////////////////////////////////////////////////////////// |
| 903 | 903 |
| 904 } // namespace rtc | 904 } // namespace rtc |
| OLD | NEW |