Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: remoting/protocol/libjingle_transport_factory.cc

Issue 10382003: Changes needed to roll libjingle r141 (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | third_party/libjingle/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/protocol/libjingle_transport_factory.h" 5 #include "remoting/protocol/libjingle_transport_factory.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "jingle/glue/channel_socket_adapter.h" 8 #include "jingle/glue/channel_socket_adapter.h"
9 #include "jingle/glue/pseudotcp_adapter.h" 9 #include "jingle/glue/pseudotcp_adapter.h"
10 #include "jingle/glue/utils.h" 10 #include "jingle/glue/utils.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "remoting/base/constants.h" 12 #include "remoting/base/constants.h"
13 #include "remoting/protocol/channel_authenticator.h" 13 #include "remoting/protocol/channel_authenticator.h"
14 #include "remoting/protocol/transport_config.h" 14 #include "remoting/protocol/transport_config.h"
15 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" 15 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
16 #include "third_party/libjingle/source/talk/base/network.h" 16 #include "third_party/libjingle/source/talk/base/network.h"
17 #include "third_party/libjingle/source/talk/p2p/base/constants.h"
17 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" 18 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h"
18 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" 19 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"
19 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" 20 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
20 21
21 namespace remoting { 22 namespace remoting {
22 namespace protocol { 23 namespace protocol {
23 24
24 namespace { 25 namespace {
25 26
26 // Value is choosen to balance the extra latency against the reduced 27 // Value is choosen to balance the extra latency against the reduced
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void NotifyConnected(scoped_ptr<net::StreamSocket> socket); 67 void NotifyConnected(scoped_ptr<net::StreamSocket> socket);
67 void NotifyConnectFailed(); 68 void NotifyConnectFailed();
68 69
69 cricket::PortAllocator* port_allocator_; 70 cricket::PortAllocator* port_allocator_;
70 bool incoming_only_; 71 bool incoming_only_;
71 72
72 std::string name_; 73 std::string name_;
73 EventHandler* event_handler_; 74 EventHandler* event_handler_;
74 StreamTransport::ConnectedCallback callback_; 75 StreamTransport::ConnectedCallback callback_;
75 scoped_ptr<ChannelAuthenticator> authenticator_; 76 scoped_ptr<ChannelAuthenticator> authenticator_;
77 std::string ice_username_fragment_;
78 std::string ice_password_;
76 79
77 scoped_ptr<cricket::P2PTransportChannel> channel_; 80 scoped_ptr<cricket::P2PTransportChannel> channel_;
78 81
79 // We own |socket_| until it is connected. 82 // We own |socket_| until it is connected.
80 scoped_ptr<jingle_glue::PseudoTcpAdapter> socket_; 83 scoped_ptr<jingle_glue::PseudoTcpAdapter> socket_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(LibjingleStreamTransport); 85 DISALLOW_COPY_AND_ASSIGN(LibjingleStreamTransport);
83 }; 86 };
84 87
85 LibjingleStreamTransport::LibjingleStreamTransport( 88 LibjingleStreamTransport::LibjingleStreamTransport(
86 cricket::PortAllocator* port_allocator, 89 cricket::PortAllocator* port_allocator,
87 bool incoming_only) 90 bool incoming_only)
88 : port_allocator_(port_allocator), 91 : port_allocator_(port_allocator),
89 incoming_only_(incoming_only), 92 incoming_only_(incoming_only),
90 event_handler_(NULL) { 93 event_handler_(NULL),
94 ice_username_fragment_(
95 talk_base::CreateRandomString(cricket::ICE_UFRAG_LENGTH)),
96 ice_password_(talk_base::CreateRandomString(cricket::ICE_PWD_LENGTH)) {
91 } 97 }
92 98
93 LibjingleStreamTransport::~LibjingleStreamTransport() { 99 LibjingleStreamTransport::~LibjingleStreamTransport() {
94 DCHECK(event_handler_); 100 DCHECK(event_handler_);
95 event_handler_->OnTransportDeleted(this); 101 event_handler_->OnTransportDeleted(this);
96 // Channel should be already destroyed if we were connected. 102 // Channel should be already destroyed if we were connected.
97 DCHECK(!is_connected() || socket_.get() == NULL); 103 DCHECK(!is_connected() || socket_.get() == NULL);
98 104
99 if (channel_.get()) { 105 if (channel_.get()) {
100 base::MessageLoopProxy::current()->DeleteSoon( 106 base::MessageLoopProxy::current()->DeleteSoon(
(...skipping 22 matching lines...) Expand all
123 const StreamTransport::ConnectedCallback& callback) { 129 const StreamTransport::ConnectedCallback& callback) {
124 DCHECK(CalledOnValidThread()); 130 DCHECK(CalledOnValidThread());
125 131
126 callback_ = callback; 132 callback_ = callback;
127 133
128 DCHECK(!channel_.get()); 134 DCHECK(!channel_.get());
129 135
130 // Create P2PTransportChannel, attach signal handlers and connect it. 136 // Create P2PTransportChannel, attach signal handlers and connect it.
131 // TODO(sergeyu): Specify correct component ID for the channel. 137 // TODO(sergeyu): Specify correct component ID for the channel.
132 channel_.reset(new cricket::P2PTransportChannel( 138 channel_.reset(new cricket::P2PTransportChannel(
133 name_, 0, NULL, port_allocator_)); 139 0, NULL, port_allocator_));
140 channel_->SetIceUfrag(ice_username_fragment_);
141 channel_->SetIcePwd(ice_password_);
134 channel_->SignalRequestSignaling.connect( 142 channel_->SignalRequestSignaling.connect(
135 this, &LibjingleStreamTransport::OnRequestSignaling); 143 this, &LibjingleStreamTransport::OnRequestSignaling);
136 channel_->SignalCandidateReady.connect( 144 channel_->SignalCandidateReady.connect(
137 this, &LibjingleStreamTransport::OnCandidateReady); 145 this, &LibjingleStreamTransport::OnCandidateReady);
138 channel_->SignalRouteChange.connect( 146 channel_->SignalRouteChange.connect(
139 this, &LibjingleStreamTransport::OnRouteChange); 147 this, &LibjingleStreamTransport::OnRouteChange);
140 channel_->set_incoming_only(incoming_only_); 148 channel_->set_incoming_only(incoming_only_);
141 149
142 channel_->Connect(); 150 channel_->Connect();
143 151
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 350 }
343 351
344 scoped_ptr<DatagramTransport> 352 scoped_ptr<DatagramTransport>
345 LibjingleTransportFactory::CreateDatagramTransport() { 353 LibjingleTransportFactory::CreateDatagramTransport() {
346 NOTIMPLEMENTED(); 354 NOTIMPLEMENTED();
347 return scoped_ptr<DatagramTransport>(NULL); 355 return scoped_ptr<DatagramTransport>(NULL);
348 } 356 }
349 357
350 } // namespace protocol 358 } // namespace protocol
351 } // namespace remoting 359 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | third_party/libjingle/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698