| 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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 } | 838 } |
| 839 | 839 |
| 840 void AsyncSocksProxyServerSocket::Error(int error) { | 840 void AsyncSocksProxyServerSocket::Error(int error) { |
| 841 state_ = SS_ERROR; | 841 state_ = SS_ERROR; |
| 842 BufferInput(false); | 842 BufferInput(false); |
| 843 Close(); | 843 Close(); |
| 844 SetError(SOCKET_EACCES); | 844 SetError(SOCKET_EACCES); |
| 845 SignalCloseEvent(this, error); | 845 SignalCloseEvent(this, error); |
| 846 } | 846 } |
| 847 | 847 |
| 848 /////////////////////////////////////////////////////////////////////////////// | |
| 849 | |
| 850 LoggingSocketAdapter::LoggingSocketAdapter(AsyncSocket* socket, | |
| 851 LoggingSeverity level, | |
| 852 const char * label, bool hex_mode) | |
| 853 : AsyncSocketAdapter(socket), level_(level), hex_mode_(hex_mode) { | |
| 854 label_.append("["); | |
| 855 label_.append(label); | |
| 856 label_.append("]"); | |
| 857 } | |
| 858 | |
| 859 int LoggingSocketAdapter::Send(const void *pv, size_t cb) { | |
| 860 int res = AsyncSocketAdapter::Send(pv, cb); | |
| 861 if (res > 0) | |
| 862 LogMultiline(level_, label_.c_str(), false, pv, res, hex_mode_, &lms_); | |
| 863 return res; | |
| 864 } | |
| 865 | |
| 866 int LoggingSocketAdapter::SendTo(const void *pv, size_t cb, | |
| 867 const SocketAddress& addr) { | |
| 868 int res = AsyncSocketAdapter::SendTo(pv, cb, addr); | |
| 869 if (res > 0) | |
| 870 LogMultiline(level_, label_.c_str(), false, pv, res, hex_mode_, &lms_); | |
| 871 return res; | |
| 872 } | |
| 873 | |
| 874 int LoggingSocketAdapter::Recv(void* pv, size_t cb, int64_t* timestamp) { | |
| 875 int res = AsyncSocketAdapter::Recv(pv, cb, timestamp); | |
| 876 if (res > 0) | |
| 877 LogMultiline(level_, label_.c_str(), true, pv, res, hex_mode_, &lms_); | |
| 878 return res; | |
| 879 } | |
| 880 | |
| 881 int LoggingSocketAdapter::RecvFrom(void* pv, | |
| 882 size_t cb, | |
| 883 SocketAddress* paddr, | |
| 884 int64_t* timestamp) { | |
| 885 int res = AsyncSocketAdapter::RecvFrom(pv, cb, paddr, timestamp); | |
| 886 if (res > 0) | |
| 887 LogMultiline(level_, label_.c_str(), true, pv, res, hex_mode_, &lms_); | |
| 888 return res; | |
| 889 } | |
| 890 | |
| 891 int LoggingSocketAdapter::Close() { | |
| 892 LogMultiline(level_, label_.c_str(), false, NULL, 0, hex_mode_, &lms_); | |
| 893 LogMultiline(level_, label_.c_str(), true, NULL, 0, hex_mode_, &lms_); | |
| 894 LOG_V(level_) << label_ << " Closed locally"; | |
| 895 return socket_->Close(); | |
| 896 } | |
| 897 | |
| 898 void LoggingSocketAdapter::OnConnectEvent(AsyncSocket * socket) { | |
| 899 LOG_V(level_) << label_ << " Connected"; | |
| 900 AsyncSocketAdapter::OnConnectEvent(socket); | |
| 901 } | |
| 902 | |
| 903 void LoggingSocketAdapter::OnCloseEvent(AsyncSocket * socket, int err) { | |
| 904 LogMultiline(level_, label_.c_str(), false, NULL, 0, hex_mode_, &lms_); | |
| 905 LogMultiline(level_, label_.c_str(), true, NULL, 0, hex_mode_, &lms_); | |
| 906 LOG_V(level_) << label_ << " Closed with error: " << err; | |
| 907 AsyncSocketAdapter::OnCloseEvent(socket, err); | |
| 908 } | |
| 909 | |
| 910 /////////////////////////////////////////////////////////////////////////////// | |
| 911 | |
| 912 } // namespace rtc | 848 } // namespace rtc |
| OLD | NEW |