| 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> |
| 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 #include <list> | 10 #include <list> |
| 9 | 11 |
| 10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 14 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 16 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 18 #include "content/renderer/media/webrtc_logging.h" | 21 #include "content/renderer/media/webrtc_logging.h" |
| 19 #include "content/renderer/p2p/host_address_request.h" | 22 #include "content/renderer/p2p/host_address_request.h" |
| 20 #include "content/renderer/p2p/socket_client_delegate.h" | 23 #include "content/renderer/p2p/socket_client_delegate.h" |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 | 732 |
| 730 IpcPacketSocketFactory::IpcPacketSocketFactory( | 733 IpcPacketSocketFactory::IpcPacketSocketFactory( |
| 731 P2PSocketDispatcher* socket_dispatcher) | 734 P2PSocketDispatcher* socket_dispatcher) |
| 732 : socket_dispatcher_(socket_dispatcher) { | 735 : socket_dispatcher_(socket_dispatcher) { |
| 733 } | 736 } |
| 734 | 737 |
| 735 IpcPacketSocketFactory::~IpcPacketSocketFactory() { | 738 IpcPacketSocketFactory::~IpcPacketSocketFactory() { |
| 736 } | 739 } |
| 737 | 740 |
| 738 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateUdpSocket( | 741 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateUdpSocket( |
| 739 const rtc::SocketAddress& local_address, uint16 min_port, uint16 max_port) { | 742 const rtc::SocketAddress& local_address, |
| 743 uint16_t min_port, |
| 744 uint16_t max_port) { |
| 740 rtc::SocketAddress crome_address; | 745 rtc::SocketAddress crome_address; |
| 741 P2PSocketClientImpl* socket_client = | 746 P2PSocketClientImpl* socket_client = |
| 742 new P2PSocketClientImpl(socket_dispatcher_); | 747 new P2PSocketClientImpl(socket_dispatcher_); |
| 743 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 748 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
| 744 // TODO(sergeyu): Respect local_address and port limits here (need | 749 // TODO(sergeyu): Respect local_address and port limits here (need |
| 745 // to pass them over IPC channel to the browser). | 750 // to pass them over IPC channel to the browser). |
| 746 if (!socket->Init(P2P_SOCKET_UDP, socket_client, | 751 if (!socket->Init(P2P_SOCKET_UDP, socket_client, |
| 747 local_address, rtc::SocketAddress())) { | 752 local_address, rtc::SocketAddress())) { |
| 748 return NULL; | 753 return NULL; |
| 749 } | 754 } |
| 750 return socket.release(); | 755 return socket.release(); |
| 751 } | 756 } |
| 752 | 757 |
| 753 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateServerTcpSocket( | 758 rtc::AsyncPacketSocket* IpcPacketSocketFactory::CreateServerTcpSocket( |
| 754 const rtc::SocketAddress& local_address, uint16 min_port, uint16 max_port, | 759 const rtc::SocketAddress& local_address, |
| 760 uint16_t min_port, |
| 761 uint16_t max_port, |
| 755 int opts) { | 762 int opts) { |
| 756 // TODO(sergeyu): Implement SSL support. | 763 // TODO(sergeyu): Implement SSL support. |
| 757 if (opts & rtc::PacketSocketFactory::OPT_SSLTCP) | 764 if (opts & rtc::PacketSocketFactory::OPT_SSLTCP) |
| 758 return NULL; | 765 return NULL; |
| 759 | 766 |
| 760 P2PSocketType type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? | 767 P2PSocketType type = (opts & rtc::PacketSocketFactory::OPT_STUN) ? |
| 761 P2P_SOCKET_STUN_TCP_SERVER : P2P_SOCKET_TCP_SERVER; | 768 P2P_SOCKET_STUN_TCP_SERVER : P2P_SOCKET_TCP_SERVER; |
| 762 P2PSocketClientImpl* socket_client = | 769 P2PSocketClientImpl* socket_client = |
| 763 new P2PSocketClientImpl(socket_dispatcher_); | 770 new P2PSocketClientImpl(socket_dispatcher_); |
| 764 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 771 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 794 } | 801 } |
| 795 | 802 |
| 796 rtc::AsyncResolverInterface* | 803 rtc::AsyncResolverInterface* |
| 797 IpcPacketSocketFactory::CreateAsyncResolver() { | 804 IpcPacketSocketFactory::CreateAsyncResolver() { |
| 798 scoped_ptr<AsyncAddressResolverImpl> resolver( | 805 scoped_ptr<AsyncAddressResolverImpl> resolver( |
| 799 new AsyncAddressResolverImpl(socket_dispatcher_)); | 806 new AsyncAddressResolverImpl(socket_dispatcher_)); |
| 800 return resolver.release(); | 807 return resolver.release(); |
| 801 } | 808 } |
| 802 | 809 |
| 803 } // namespace content | 810 } // namespace content |
| OLD | NEW |