diff options
Diffstat (limited to 'content/renderer/p2p')
-rw-r--r-- | content/renderer/p2p/p2p_transport_impl.cc | 8 | ||||
-rw-r--r-- | content/renderer/p2p/p2p_transport_impl.h | 15 | ||||
-rw-r--r-- | content/renderer/p2p/p2p_transport_impl_unittest.cc | 21 |
3 files changed, 23 insertions, 21 deletions
diff --git a/content/renderer/p2p/p2p_transport_impl.cc b/content/renderer/p2p/p2p_transport_impl.cc index d5f2afe..2353134 100644 --- a/content/renderer/p2p/p2p_transport_impl.cc +++ b/content/renderer/p2p/p2p_transport_impl.cc @@ -23,6 +23,11 @@ P2PTransportImpl::P2PTransportImpl( socket_factory_(socket_factory) { } +P2PTransportImpl::P2PTransportImpl(P2PSocketDispatcher* socket_dispatcher) + : network_manager_(new IpcNetworkManager(socket_dispatcher)), + socket_factory_(new IpcPacketSocketFactory(socket_dispatcher)) { +} + P2PTransportImpl::~P2PTransportImpl() { } @@ -40,8 +45,9 @@ bool P2PTransportImpl::Init(const std::string& name, const std::string& config, // TODO(sergeyu): Implement PortAllocator that can parse |config| // and use it here instead of BasicPortAllocator. allocator_.reset(new cricket::BasicPortAllocator( - network_manager_, socket_factory_)); + network_manager_.get(), socket_factory_.get())); + DCHECK(!channel_.get()); channel_.reset(new cricket::P2PTransportChannel( name, "", NULL, allocator_.get())); channel_->SignalRequestSignaling.connect( diff --git a/content/renderer/p2p/p2p_transport_impl.h b/content/renderer/p2p/p2p_transport_impl.h index d473614..2c8b947 100644 --- a/content/renderer/p2p/p2p_transport_impl.h +++ b/content/renderer/p2p/p2p_transport_impl.h @@ -10,7 +10,7 @@ #include "third_party/libjingle/source/talk/base/sigslot.h" #include "webkit/glue/p2p_transport.h" -class RenderView; +class P2PSocketDispatcher; namespace cricket { class Candidate; @@ -33,11 +33,16 @@ class P2PTransportImpl : public webkit_glue::P2PTransport, public sigslot::has_slots<> { public: // Create P2PTransportImpl using specified NetworkManager and - // PacketSocketFactory. Caller keeps ownership of |network_manager| - // and |socket_factory|. + // PacketSocketFactory. Takes ownership of |network_manager| and + // |socket_factory|. P2PTransportImpl(talk_base::NetworkManager* network_manager, talk_base::PacketSocketFactory* socket_factory); + // Creates P2PTransportImpl using specified + // P2PSocketDispatcher. This constructor creates IpcNetworkManager + // and IpcPacketSocketFactory, and keeps ownership of these objects. + P2PTransportImpl(P2PSocketDispatcher* socket_dispatcher); + virtual ~P2PTransportImpl(); // webkit_glue::P2PTransport interface. @@ -63,8 +68,8 @@ class P2PTransportImpl : public webkit_glue::P2PTransport, EventHandler* event_handler_; State state_; - talk_base::NetworkManager* network_manager_; - talk_base::PacketSocketFactory* socket_factory_; + scoped_ptr<talk_base::NetworkManager> network_manager_; + scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; scoped_ptr<cricket::PortAllocator> allocator_; scoped_ptr<cricket::P2PTransportChannel> channel_; diff --git a/content/renderer/p2p/p2p_transport_impl_unittest.cc b/content/renderer/p2p/p2p_transport_impl_unittest.cc index f7b9bfe..393fd0d 100644 --- a/content/renderer/p2p/p2p_transport_impl_unittest.cc +++ b/content/renderer/p2p/p2p_transport_impl_unittest.cc @@ -203,28 +203,19 @@ class P2PTransportImplTest : public testing::Test { net::IPAddressNumber ip; ASSERT_TRUE(net::ParseIPLiteralToNumber(kTestAddress1, &ip)); - network_manager1_.reset(new jingle_glue::FakeNetworkManager(ip)); - socket_factory1_.reset( - new jingle_glue::FakeSocketFactory(socket_manager_, ip)); - transport1_.reset(new P2PTransportImpl(network_manager1_.get(), - socket_factory1_.get())); + transport1_.reset(new P2PTransportImpl( + new jingle_glue::FakeNetworkManager(ip), + new jingle_glue::FakeSocketFactory(socket_manager_, ip))); ASSERT_TRUE(net::ParseIPLiteralToNumber(kTestAddress2, &ip)); - network_manager2_.reset(new jingle_glue::FakeNetworkManager(ip)); - socket_factory2_.reset( - new jingle_glue::FakeSocketFactory(socket_manager_, ip)); - transport2_.reset(new P2PTransportImpl(network_manager2_.get(), - socket_factory2_.get())); + transport2_.reset(new P2PTransportImpl( + new jingle_glue::FakeNetworkManager(ip), + new jingle_glue::FakeSocketFactory(socket_manager_, ip))); } MessageLoop message_loop_; - scoped_ptr<jingle_glue::FakeNetworkManager> network_manager1_; - scoped_ptr<jingle_glue::FakeNetworkManager> network_manager2_; scoped_refptr<jingle_glue::FakeSocketManager> socket_manager_; - scoped_ptr<jingle_glue::FakeSocketFactory> socket_factory1_; - scoped_ptr<jingle_glue::FakeSocketFactory> socket_factory2_; - scoped_ptr<P2PTransportImpl> transport1_; MockP2PEventHandler event_handler1_; scoped_ptr<P2PTransportImpl> transport2_; |