| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // Implements a socket adapter that can buffer and process data internally, | 30 // Implements a socket adapter that can buffer and process data internally, |
| 31 // as in the case of connecting to a proxy, where you must speak the proxy | 31 // as in the case of connecting to a proxy, where you must speak the proxy |
| 32 // protocol before commencing normal socket behavior. | 32 // protocol before commencing normal socket behavior. |
| 33 class BufferedReadAdapter : public AsyncSocketAdapter { | 33 class BufferedReadAdapter : public AsyncSocketAdapter { |
| 34 public: | 34 public: |
| 35 BufferedReadAdapter(AsyncSocket* socket, size_t buffer_size); | 35 BufferedReadAdapter(AsyncSocket* socket, size_t buffer_size); |
| 36 ~BufferedReadAdapter() override; | 36 ~BufferedReadAdapter() override; |
| 37 | 37 |
| 38 int Send(const void* pv, size_t cb) override; | 38 int Send(const void* pv, size_t cb) override; |
| 39 int Recv(void* pv, size_t cb) override; | 39 int Recv(void* pv, size_t cb, int64_t* timestamp) override; |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 int DirectSend(const void* pv, size_t cb) { | 42 int DirectSend(const void* pv, size_t cb) { |
| 43 return AsyncSocketAdapter::Send(pv, cb); | 43 return AsyncSocketAdapter::Send(pv, cb); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void BufferInput(bool on = true); | 46 void BufferInput(bool on = true); |
| 47 virtual void ProcessInput(char* data, size_t* len) = 0; | 47 virtual void ProcessInput(char* data, size_t* len) = 0; |
| 48 | 48 |
| 49 void OnReadEvent(AsyncSocket* socket) override; | 49 void OnReadEvent(AsyncSocket* socket) override; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 /////////////////////////////////////////////////////////////////////////////// | 217 /////////////////////////////////////////////////////////////////////////////// |
| 218 | 218 |
| 219 // Implements a socket adapter that logs everything that it sends and receives. | 219 // Implements a socket adapter that logs everything that it sends and receives. |
| 220 class LoggingSocketAdapter : public AsyncSocketAdapter { | 220 class LoggingSocketAdapter : public AsyncSocketAdapter { |
| 221 public: | 221 public: |
| 222 LoggingSocketAdapter(AsyncSocket* socket, LoggingSeverity level, | 222 LoggingSocketAdapter(AsyncSocket* socket, LoggingSeverity level, |
| 223 const char * label, bool hex_mode = false); | 223 const char * label, bool hex_mode = false); |
| 224 | 224 |
| 225 int Send(const void* pv, size_t cb) override; | 225 int Send(const void* pv, size_t cb) override; |
| 226 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; | 226 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; |
| 227 int Recv(void* pv, size_t cb) override; | 227 int Recv(void* pv, size_t cb, int64_t* timestamp) override; |
| 228 int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) override; | 228 int RecvFrom(void* pv, |
| 229 size_t cb, |
| 230 SocketAddress* paddr, |
| 231 int64_t* timestamp) override; |
| 229 int Close() override; | 232 int Close() override; |
| 230 | 233 |
| 231 protected: | 234 protected: |
| 232 void OnConnectEvent(AsyncSocket* socket) override; | 235 void OnConnectEvent(AsyncSocket* socket) override; |
| 233 void OnCloseEvent(AsyncSocket* socket, int err) override; | 236 void OnCloseEvent(AsyncSocket* socket, int err) override; |
| 234 | 237 |
| 235 private: | 238 private: |
| 236 LoggingSeverity level_; | 239 LoggingSeverity level_; |
| 237 std::string label_; | 240 std::string label_; |
| 238 bool hex_mode_; | 241 bool hex_mode_; |
| 239 LogMultilineState lms_; | 242 LogMultilineState lms_; |
| 240 RTC_DISALLOW_COPY_AND_ASSIGN(LoggingSocketAdapter); | 243 RTC_DISALLOW_COPY_AND_ASSIGN(LoggingSocketAdapter); |
| 241 }; | 244 }; |
| 242 | 245 |
| 243 /////////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////////// |
| 244 | 247 |
| 245 } // namespace rtc | 248 } // namespace rtc |
| 246 | 249 |
| 247 #endif // WEBRTC_BASE_SOCKETADAPTERS_H_ | 250 #endif // WEBRTC_BASE_SOCKETADAPTERS_H_ |
| OLD | NEW |