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 | 
| 11 #ifndef WEBRTC_BASE_ASYNCSOCKET_H_ | 11 #ifndef WEBRTC_BASE_ASYNCSOCKET_H_ | 
| 12 #define WEBRTC_BASE_ASYNCSOCKET_H_ | 12 #define WEBRTC_BASE_ASYNCSOCKET_H_ | 
| 13 | 13 | 
| 14 #include "webrtc/base/common.h" | 14 #include "webrtc/base/common.h" | 
| 15 #include "webrtc/base/sigslot.h" | 15 #include "webrtc/base/sigslot.h" | 
| 16 #include "webrtc/base/socket.h" | 16 #include "webrtc/base/socket.h" | 
| 17 | 17 | 
| 18 namespace rtc { | 18 namespace rtc { | 
| 19 | 19 | 
| 20 // TODO: Remove Socket and rename AsyncSocket to Socket. | 20 // TODO: Remove Socket and rename AsyncSocket to Socket. | 
| 21 | 21 | 
| 22 // Provides the ability to perform socket I/O asynchronously. | 22 // Provides the ability to perform socket I/O asynchronously. | 
| 23 class AsyncSocket : public Socket { | 23 class AsyncSocket : public Socket { | 
| 24 public: | 24 public: | 
| 25 AsyncSocket(); | 25 AsyncSocket(); | 
| 26 ~AsyncSocket() override; | 26 ~AsyncSocket() override; | 
| 27 | 27 | 
| 28 AsyncSocket* Accept(SocketAddress* paddr) override = 0; | 28 AsyncSocket* Accept(SocketAddress* paddr) override = 0; | 
| 29 | 29 | 
| 30 virtual int BindToNetwork(NetworkHandle handle) = 0; | |
| 
 
pthatcher1
2016/01/06 21:58:46
Can you put a comment explaining when this should
 
honghaiz3
2016/01/12 20:36:41
Acknowledged.
 
 | |
| 31 | |
| 30 // SignalReadEvent and SignalWriteEvent use multi_threaded_local to allow | 32 // SignalReadEvent and SignalWriteEvent use multi_threaded_local to allow | 
| 31 // access concurrently from different thread. | 33 // access concurrently from different thread. | 
| 32 // For example SignalReadEvent::connect will be called in AsyncUDPSocket ctor | 34 // For example SignalReadEvent::connect will be called in AsyncUDPSocket ctor | 
| 33 // but at the same time the SocketDispatcher maybe signaling the read event. | 35 // but at the same time the SocketDispatcher maybe signaling the read event. | 
| 34 // ready to read | 36 // ready to read | 
| 35 sigslot::signal1<AsyncSocket*, | 37 sigslot::signal1<AsyncSocket*, | 
| 36 sigslot::multi_threaded_local> SignalReadEvent; | 38 sigslot::multi_threaded_local> SignalReadEvent; | 
| 37 // ready to write | 39 // ready to write | 
| 38 sigslot::signal1<AsyncSocket*, | 40 sigslot::signal1<AsyncSocket*, | 
| 39 sigslot::multi_threaded_local> SignalWriteEvent; | 41 sigslot::multi_threaded_local> SignalWriteEvent; | 
| (...skipping 13 matching lines...) Expand all Loading... | |
| 53 SocketAddress GetLocalAddress() const override; | 55 SocketAddress GetLocalAddress() const override; | 
| 54 SocketAddress GetRemoteAddress() const override; | 56 SocketAddress GetRemoteAddress() const override; | 
| 55 int Bind(const SocketAddress& addr) override; | 57 int Bind(const SocketAddress& addr) override; | 
| 56 int Connect(const SocketAddress& addr) override; | 58 int Connect(const SocketAddress& addr) override; | 
| 57 int Send(const void* pv, size_t cb) override; | 59 int Send(const void* pv, size_t cb) override; | 
| 58 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; | 60 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; | 
| 59 int Recv(void* pv, size_t cb) override; | 61 int Recv(void* pv, size_t cb) override; | 
| 60 int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) override; | 62 int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) override; | 
| 61 int Listen(int backlog) override; | 63 int Listen(int backlog) override; | 
| 62 AsyncSocket* Accept(SocketAddress* paddr) override; | 64 AsyncSocket* Accept(SocketAddress* paddr) override; | 
| 65 int BindToNetwork(NetworkHandle handle) override; | |
| 63 int Close() override; | 66 int Close() override; | 
| 64 int GetError() const override; | 67 int GetError() const override; | 
| 65 void SetError(int error) override; | 68 void SetError(int error) override; | 
| 66 ConnState GetState() const override; | 69 ConnState GetState() const override; | 
| 67 int EstimateMTU(uint16_t* mtu) override; | 70 int EstimateMTU(uint16_t* mtu) override; | 
| 68 int GetOption(Option opt, int* value) override; | 71 int GetOption(Option opt, int* value) override; | 
| 69 int SetOption(Option opt, int value) override; | 72 int SetOption(Option opt, int value) override; | 
| 70 | 73 | 
| 71 protected: | 74 protected: | 
| 72 virtual void OnConnectEvent(AsyncSocket* socket); | 75 virtual void OnConnectEvent(AsyncSocket* socket); | 
| 73 virtual void OnReadEvent(AsyncSocket* socket); | 76 virtual void OnReadEvent(AsyncSocket* socket); | 
| 74 virtual void OnWriteEvent(AsyncSocket* socket); | 77 virtual void OnWriteEvent(AsyncSocket* socket); | 
| 75 virtual void OnCloseEvent(AsyncSocket* socket, int err); | 78 virtual void OnCloseEvent(AsyncSocket* socket, int err); | 
| 76 | 79 | 
| 77 AsyncSocket* socket_; | 80 AsyncSocket* socket_; | 
| 78 }; | 81 }; | 
| 79 | 82 | 
| 80 } // namespace rtc | 83 } // namespace rtc | 
| 81 | 84 | 
| 82 #endif // WEBRTC_BASE_ASYNCSOCKET_H_ | 85 #endif // WEBRTC_BASE_ASYNCSOCKET_H_ | 
| OLD | NEW |