| 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 "content/renderer/p2p/ipc_socket_factory.h" | 5 #include "content/renderer/p2p/ipc_socket_factory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 public: | 71 public: |
| 72 IpcPacketSocket(); | 72 IpcPacketSocket(); |
| 73 virtual ~IpcPacketSocket(); | 73 virtual ~IpcPacketSocket(); |
| 74 | 74 |
| 75 // Always takes ownership of client even if initialization fails. | 75 // Always takes ownership of client even if initialization fails. |
| 76 bool Init(P2PSocketType type, P2PSocketClientImpl* client, | 76 bool Init(P2PSocketType type, P2PSocketClientImpl* client, |
| 77 const rtc::SocketAddress& local_address, | 77 const rtc::SocketAddress& local_address, |
| 78 const rtc::SocketAddress& remote_address); | 78 const rtc::SocketAddress& remote_address); |
| 79 | 79 |
| 80 // rtc::AsyncPacketSocket interface. | 80 // rtc::AsyncPacketSocket interface. |
| 81 virtual rtc::SocketAddress GetLocalAddress() const OVERRIDE; | 81 virtual rtc::SocketAddress GetLocalAddress() const override; |
| 82 virtual rtc::SocketAddress GetRemoteAddress() const OVERRIDE; | 82 virtual rtc::SocketAddress GetRemoteAddress() const override; |
| 83 virtual int Send(const void *pv, size_t cb, | 83 virtual int Send(const void *pv, size_t cb, |
| 84 const rtc::PacketOptions& options) OVERRIDE; | 84 const rtc::PacketOptions& options) override; |
| 85 virtual int SendTo(const void *pv, size_t cb, | 85 virtual int SendTo(const void *pv, size_t cb, |
| 86 const rtc::SocketAddress& addr, | 86 const rtc::SocketAddress& addr, |
| 87 const rtc::PacketOptions& options) OVERRIDE; | 87 const rtc::PacketOptions& options) override; |
| 88 virtual int Close() OVERRIDE; | 88 virtual int Close() override; |
| 89 virtual State GetState() const OVERRIDE; | 89 virtual State GetState() const override; |
| 90 virtual int GetOption(rtc::Socket::Option option, int* value) OVERRIDE; | 90 virtual int GetOption(rtc::Socket::Option option, int* value) override; |
| 91 virtual int SetOption(rtc::Socket::Option option, int value) OVERRIDE; | 91 virtual int SetOption(rtc::Socket::Option option, int value) override; |
| 92 virtual int GetError() const OVERRIDE; | 92 virtual int GetError() const override; |
| 93 virtual void SetError(int error) OVERRIDE; | 93 virtual void SetError(int error) override; |
| 94 | 94 |
| 95 // P2PSocketClientDelegate implementation. | 95 // P2PSocketClientDelegate implementation. |
| 96 virtual void OnOpen(const net::IPEndPoint& local_address, | 96 virtual void OnOpen(const net::IPEndPoint& local_address, |
| 97 const net::IPEndPoint& remote_address) OVERRIDE; | 97 const net::IPEndPoint& remote_address) override; |
| 98 virtual void OnIncomingTcpConnection( | 98 virtual void OnIncomingTcpConnection( |
| 99 const net::IPEndPoint& address, | 99 const net::IPEndPoint& address, |
| 100 P2PSocketClient* client) OVERRIDE; | 100 P2PSocketClient* client) override; |
| 101 virtual void OnSendComplete() OVERRIDE; | 101 virtual void OnSendComplete() override; |
| 102 virtual void OnError() OVERRIDE; | 102 virtual void OnError() override; |
| 103 virtual void OnDataReceived(const net::IPEndPoint& address, | 103 virtual void OnDataReceived(const net::IPEndPoint& address, |
| 104 const std::vector<char>& data, | 104 const std::vector<char>& data, |
| 105 const base::TimeTicks& timestamp) OVERRIDE; | 105 const base::TimeTicks& timestamp) override; |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 enum InternalState { | 108 enum InternalState { |
| 109 IS_UNINITIALIZED, | 109 IS_UNINITIALIZED, |
| 110 IS_OPENING, | 110 IS_OPENING, |
| 111 IS_OPEN, | 111 IS_OPEN, |
| 112 IS_CLOSED, | 112 IS_CLOSED, |
| 113 IS_ERROR, | 113 IS_ERROR, |
| 114 }; | 114 }; |
| 115 | 115 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // P2PAsyncAddressResolver. Libjingle sig slots are not thread safe. In case | 168 // P2PAsyncAddressResolver. Libjingle sig slots are not thread safe. In case |
| 169 // of MT sig slots clients must call disconnect. This class is to make sure | 169 // of MT sig slots clients must call disconnect. This class is to make sure |
| 170 // we destruct from the same thread on which is created. | 170 // we destruct from the same thread on which is created. |
| 171 class AsyncAddressResolverImpl : public base::NonThreadSafe, | 171 class AsyncAddressResolverImpl : public base::NonThreadSafe, |
| 172 public rtc::AsyncResolverInterface { | 172 public rtc::AsyncResolverInterface { |
| 173 public: | 173 public: |
| 174 AsyncAddressResolverImpl(P2PSocketDispatcher* dispatcher); | 174 AsyncAddressResolverImpl(P2PSocketDispatcher* dispatcher); |
| 175 virtual ~AsyncAddressResolverImpl(); | 175 virtual ~AsyncAddressResolverImpl(); |
| 176 | 176 |
| 177 // rtc::AsyncResolverInterface interface. | 177 // rtc::AsyncResolverInterface interface. |
| 178 virtual void Start(const rtc::SocketAddress& addr) OVERRIDE; | 178 virtual void Start(const rtc::SocketAddress& addr) override; |
| 179 virtual bool GetResolvedAddress( | 179 virtual bool GetResolvedAddress( |
| 180 int family, rtc::SocketAddress* addr) const OVERRIDE; | 180 int family, rtc::SocketAddress* addr) const override; |
| 181 virtual int GetError() const OVERRIDE; | 181 virtual int GetError() const override; |
| 182 virtual void Destroy(bool wait) OVERRIDE; | 182 virtual void Destroy(bool wait) override; |
| 183 | 183 |
| 184 private: | 184 private: |
| 185 virtual void OnAddressResolved(const net::IPAddressList& addresses); | 185 virtual void OnAddressResolved(const net::IPAddressList& addresses); |
| 186 | 186 |
| 187 scoped_refptr<P2PAsyncAddressResolver> resolver_; | 187 scoped_refptr<P2PAsyncAddressResolver> resolver_; |
| 188 int port_; // Port number in |addr| from Start() method. | 188 int port_; // Port number in |addr| from Start() method. |
| 189 std::vector<rtc::IPAddress> addresses_; // Resolved addresses. | 189 std::vector<rtc::IPAddress> addresses_; // Resolved addresses. |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 IpcPacketSocket::IpcPacketSocket() | 192 IpcPacketSocket::IpcPacketSocket() |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 } | 670 } |
| 671 | 671 |
| 672 rtc::AsyncResolverInterface* | 672 rtc::AsyncResolverInterface* |
| 673 IpcPacketSocketFactory::CreateAsyncResolver() { | 673 IpcPacketSocketFactory::CreateAsyncResolver() { |
| 674 scoped_ptr<AsyncAddressResolverImpl> resolver( | 674 scoped_ptr<AsyncAddressResolverImpl> resolver( |
| 675 new AsyncAddressResolverImpl(socket_dispatcher_)); | 675 new AsyncAddressResolverImpl(socket_dispatcher_)); |
| 676 return resolver.release(); | 676 return resolver.release(); |
| 677 } | 677 } |
| 678 | 678 |
| 679 } // namespace content | 679 } // namespace content |
| OLD | NEW |