OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_P2P_P2P_TRANSPORT_IMPL_H_ | |
6 #define CONTENT_RENDERER_P2P_P2P_TRANSPORT_IMPL_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "content/common/content_export.h" | |
14 #include "net/base/completion_callback.h" | |
15 #include "third_party/libjingle/source/talk/base/sigslot.h" | |
16 #include "webkit/glue/p2p_transport.h" | |
17 | |
18 namespace cricket { | |
19 class Candidate; | |
20 class PortAllocator; | |
21 class P2PTransportChannel; | |
22 class TransportChannel; | |
23 class TransportChannelImpl; | |
24 } // namespace cricket | |
25 | |
26 namespace jingle_glue { | |
27 class TransportChannelSocketAdapter; | |
28 class PseudoTcpAdapter; | |
29 } // namespace jingle_glue | |
30 | |
31 namespace talk_base { | |
32 class NetworkManager; | |
33 class PacketSocketFactory; | |
34 } // namespace talk_base | |
35 | |
36 namespace content { | |
37 | |
38 class P2PSocketDispatcher; | |
39 | |
40 class CONTENT_EXPORT P2PTransportImpl | |
41 : NON_EXPORTED_BASE(public webkit_glue::P2PTransport), | |
42 public sigslot::has_slots<> { | |
43 public: | |
44 // Creates P2PTransportImpl using specified NetworkManager and | |
45 // PacketSocketFactory. Takes ownership of |network_manager| and | |
46 // |socket_factory|. Provided to be used for tests only. | |
47 P2PTransportImpl(talk_base::NetworkManager* network_manager, | |
48 talk_base::PacketSocketFactory* socket_factory); | |
49 | |
50 // Creates P2PTransportImpl using specified | |
51 // P2PSocketDispatcher. This constructor creates IpcNetworkManager | |
52 // and IpcPacketSocketFactory, and keeps ownership of these objects. | |
53 explicit P2PTransportImpl(P2PSocketDispatcher* socket_dispatcher); | |
54 | |
55 virtual ~P2PTransportImpl(); | |
56 | |
57 // webkit_glue::P2PTransport interface. | |
58 virtual bool Init(WebKit::WebFrame* web_frame, | |
59 const std::string& name, | |
60 Protocol protocol, | |
61 const Config& config, | |
62 EventHandler* event_handler) OVERRIDE; | |
63 virtual bool AddRemoteCandidate(const std::string& address) OVERRIDE; | |
64 virtual net::Socket* GetChannel() OVERRIDE; | |
65 | |
66 private: | |
67 class ChannelAdapter; | |
68 | |
69 void OnRequestSignaling(cricket::TransportChannelImpl* channel); | |
70 void OnCandidateReady(cricket::TransportChannelImpl* channel, | |
71 const cricket::Candidate& candidate); | |
72 void OnReadableState(cricket::TransportChannel* channel); | |
73 void OnWriteableState(cricket::TransportChannel* channel); | |
74 | |
75 void OnTcpConnected(int result); | |
76 | |
77 P2PSocketDispatcher* socket_dispatcher_; | |
78 std::string name_; | |
79 EventHandler* event_handler_; | |
80 State state_; | |
81 | |
82 scoped_ptr<talk_base::NetworkManager> network_manager_; | |
83 scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; | |
84 | |
85 scoped_ptr<cricket::PortAllocator> allocator_; | |
86 scoped_ptr<cricket::P2PTransportChannel> channel_; | |
87 | |
88 scoped_ptr<jingle_glue::TransportChannelSocketAdapter> channel_adapter_; | |
89 scoped_ptr<jingle_glue::PseudoTcpAdapter> pseudo_tcp_adapter_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(P2PTransportImpl); | |
92 }; | |
93 | |
94 } // namespace content | |
95 | |
96 #endif // CONTENT_RENDERER_P2P_P2P_TRANSPORT_IMPL_H_ | |
OLD | NEW |