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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 } | 757 } |
758 return socket.release(); | 758 return socket.release(); |
759 } | 759 } |
760 | 760 |
761 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateServerTcpSocket( | 761 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateServerTcpSocket( |
762 const rtc::SocketAddress& local_address, | 762 const rtc::SocketAddress& local_address, |
763 uint16_t min_port, | 763 uint16_t min_port, |
764 uint16_t max_port, | 764 uint16_t max_port, |
765 int opts) { | 765 int opts) { |
766 // TODO(sergeyu): Implement SSL support. | 766 // TODO(sergeyu): Implement SSL support. |
767 if (opts & rtc::PacketSocketFactory::OPT_SSLTCP) | 767 if (opts & rtc::PacketSocketFactory::OPT_TLS_FAKE) |
768 return NULL; | 768 return NULL; |
769 | 769 |
770 P2PSocketType type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? | 770 P2PSocketType type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? |
771 P2P_SOCKET_STUN_TCP_SERVER : P2P_SOCKET_TCP_SERVER; | 771 P2P_SOCKET_STUN_TCP_SERVER : P2P_SOCKET_TCP_SERVER; |
772 P2PSocketClientImpl* socket_client = | 772 P2PSocketClientImpl* socket_client = |
773 new P2PSocketClientImpl(socket_dispatcher_); | 773 new P2PSocketClientImpl(socket_dispatcher_); |
774 std::unique_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 774 std::unique_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
775 if (!socket->Init(type, socket_client, local_address, min_port, max_port, | 775 if (!socket->Init(type, socket_client, local_address, min_port, max_port, |
776 rtc::SocketAddress())) { | 776 rtc::SocketAddress())) { |
777 return NULL; | 777 return NULL; |
778 } | 778 } |
779 return socket.release(); | 779 return socket.release(); |
780 } | 780 } |
781 | 781 |
782 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateClientTcpSocket( | 782 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateClientTcpSocket( |
783 const rtc::SocketAddress& local_address, | 783 const rtc::SocketAddress& local_address, |
784 const rtc::SocketAddress& remote_address, | 784 const rtc::SocketAddress& remote_address, |
785 const rtc::ProxyInfo& proxy_info, | 785 const rtc::ProxyInfo& proxy_info, |
786 const std::string& user_agent, int opts) { | 786 const std::string& user_agent, int opts) { |
787 P2PSocketType type; | 787 P2PSocketType type; |
788 if (opts & rtc::PacketSocketFactory::OPT_SSLTCP) { | 788 if (opts & rtc::PacketSocketFactory::OPT_TLS_FAKE) { |
789 type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? | 789 type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? |
790 P2P_SOCKET_STUN_SSLTCP_CLIENT : P2P_SOCKET_SSLTCP_CLIENT; | 790 P2P_SOCKET_STUN_SSLTCP_CLIENT : P2P_SOCKET_SSLTCP_CLIENT; |
791 } else if (opts & rtc::PacketSocketFactory::OPT_TLS) { | 791 } else if (opts & rtc::PacketSocketFactory::OPT_TLS) { |
792 type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? | 792 type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? |
793 P2P_SOCKET_STUN_TLS_CLIENT : P2P_SOCKET_TLS_CLIENT; | 793 P2P_SOCKET_STUN_TLS_CLIENT : P2P_SOCKET_TLS_CLIENT; |
794 } else { | 794 } else { |
795 type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? | 795 type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? |
796 P2P_SOCKET_STUN_TCP_CLIENT : P2P_SOCKET_TCP_CLIENT; | 796 P2P_SOCKET_STUN_TCP_CLIENT : P2P_SOCKET_TCP_CLIENT; |
797 } | 797 } |
798 P2PSocketClientImpl* socket_client = | 798 P2PSocketClientImpl* socket_client = |
799 new P2PSocketClientImpl(socket_dispatcher_); | 799 new P2PSocketClientImpl(socket_dispatcher_); |
800 std::unique_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 800 std::unique_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
801 if (!socket->Init(type, socket_client, local_address, 0, 0, remote_address)) | 801 if (!socket->Init(type, socket_client, local_address, 0, 0, remote_address)) |
802 return NULL; | 802 return NULL; |
803 return socket.release(); | 803 return socket.release(); |
804 } | 804 } |
805 | 805 |
806 rtc::AsyncResolverInterface* | 806 rtc::AsyncResolverInterface* |
807 IpcPacketSocketFactory::CreateAsyncResolver() { | 807 IpcPacketSocketFactory::CreateAsyncResolver() { |
808 std::unique_ptr<AsyncAddressResolverImpl> resolver( | 808 std::unique_ptr<AsyncAddressResolverImpl> resolver( |
809 new AsyncAddressResolverImpl(socket_dispatcher_)); | 809 new AsyncAddressResolverImpl(socket_dispatcher_)); |
810 return resolver.release(); | 810 return resolver.release(); |
811 } | 811 } |
812 | 812 |
813 } // namespace content | 813 } // namespace content |
OLD | NEW |