blob: d47361437d262f9504c634752f94383c183cb720 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_P2P_P2P_TRANSPORT_IMPL_H_
#define CONTENT_RENDERER_P2P_P2P_TRANSPORT_IMPL_H_
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "third_party/libjingle/source/talk/base/sigslot.h"
#include "webkit/glue/p2p_transport.h"
class RenderView;
namespace cricket {
class Candidate;
class PortAllocator;
class P2PTransportChannel;
class TransportChannel;
class TransportChannelImpl;
} // namespace cricket
namespace jingle_glue {
class TransportChannelSocketAdapter;
} // namespace jingle_glue
namespace talk_base {
class NetworkManager;
class PacketSocketFactory;
} // namespace talk_base
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|.
P2PTransportImpl(talk_base::NetworkManager* network_manager,
talk_base::PacketSocketFactory* socket_factory);
virtual ~P2PTransportImpl();
// webkit_glue::P2PTransport interface.
virtual bool Init(const std::string& name, const std::string& config,
EventHandler* event_handler) OVERRIDE;
virtual bool AddRemoteCandidate(const std::string& address) OVERRIDE;
virtual net::Socket* GetChannel() OVERRIDE;
private:
class ChannelAdapter;
void OnRequestSignaling();
void OnCandidateReady(cricket::TransportChannelImpl* channel,
const cricket::Candidate& candidate);
void OnReadableState(cricket::TransportChannel* channel);
void OnWriteableState(cricket::TransportChannel* channel);
std::string SerializeCandidate(const cricket::Candidate& candidate);
bool DeserializeCandidate(const std::string& address,
cricket::Candidate* candidate);
std::string name_;
EventHandler* event_handler_;
State state_;
talk_base::NetworkManager* network_manager_;
talk_base::PacketSocketFactory* socket_factory_;
scoped_ptr<cricket::PortAllocator> allocator_;
scoped_ptr<cricket::P2PTransportChannel> channel_;
scoped_ptr<jingle_glue::TransportChannelSocketAdapter> channel_adapter_;
DISALLOW_COPY_AND_ASSIGN(P2PTransportImpl);
};
#endif // CONTENT_RENDERER_P2P_P2P_TRANSPORT_IMPL_H_
|