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

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

Issue 429113002: Webrtc deps roll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use webrtc version 6825 and rebase and switch back to original workspace. Created 6 years, 4 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/libjingle_transport_factory.h ('k') | remoting/protocol/message_decoder.cc » ('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/callback.h" 7 #include "base/callback.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 #include "jingle/glue/channel_socket_adapter.h" 11 #include "jingle/glue/channel_socket_adapter.h"
12 #include "jingle/glue/pseudotcp_adapter.h" 12 #include "jingle/glue/pseudotcp_adapter.h"
13 #include "jingle/glue/utils.h" 13 #include "jingle/glue/utils.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "remoting/base/constants.h" 15 #include "remoting/base/constants.h"
16 #include "remoting/protocol/channel_authenticator.h" 16 #include "remoting/protocol/channel_authenticator.h"
17 #include "remoting/protocol/network_settings.h" 17 #include "remoting/protocol/network_settings.h"
18 #include "remoting/signaling/jingle_info_request.h" 18 #include "remoting/signaling/jingle_info_request.h"
19 #include "third_party/libjingle/source/talk/base/network.h"
20 #include "third_party/libjingle/source/talk/p2p/base/constants.h" 19 #include "third_party/libjingle/source/talk/p2p/base/constants.h"
21 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" 20 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h"
22 #include "third_party/libjingle/source/talk/p2p/base/port.h" 21 #include "third_party/libjingle/source/talk/p2p/base/port.h"
23 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" 22 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"
24 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" 23 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
24 #include "third_party/webrtc/base/network.h"
25 25
26 namespace remoting { 26 namespace remoting {
27 namespace protocol { 27 namespace protocol {
28 28
29 namespace { 29 namespace {
30 30
31 // Value is chosen to balance the extra latency against the reduced 31 // Value is chosen to balance the extra latency against the reduced
32 // load due to ACK traffic. 32 // load due to ACK traffic.
33 const int kTcpAckDelayMilliseconds = 10; 33 const int kTcpAckDelayMilliseconds = 10;
34 34
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 DISALLOW_COPY_AND_ASSIGN(LibjingleStreamTransport); 120 DISALLOW_COPY_AND_ASSIGN(LibjingleStreamTransport);
121 }; 121 };
122 122
123 LibjingleStreamTransport::LibjingleStreamTransport( 123 LibjingleStreamTransport::LibjingleStreamTransport(
124 cricket::PortAllocator* port_allocator, 124 cricket::PortAllocator* port_allocator,
125 const NetworkSettings& network_settings) 125 const NetworkSettings& network_settings)
126 : port_allocator_(port_allocator), 126 : port_allocator_(port_allocator),
127 network_settings_(network_settings), 127 network_settings_(network_settings),
128 event_handler_(NULL), 128 event_handler_(NULL),
129 ice_username_fragment_( 129 ice_username_fragment_(
130 talk_base::CreateRandomString(cricket::ICE_UFRAG_LENGTH)), 130 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH)),
131 ice_password_(talk_base::CreateRandomString(cricket::ICE_PWD_LENGTH)), 131 ice_password_(rtc::CreateRandomString(cricket::ICE_PWD_LENGTH)),
132 can_start_(false), 132 can_start_(false),
133 channel_was_writable_(false), 133 channel_was_writable_(false),
134 connect_attempts_left_(kMaxReconnectAttempts) { 134 connect_attempts_left_(kMaxReconnectAttempts) {
135 DCHECK(!ice_username_fragment_.empty()); 135 DCHECK(!ice_username_fragment_.empty());
136 DCHECK(!ice_password_.empty()); 136 DCHECK(!ice_password_.empty());
137 } 137 }
138 138
139 LibjingleStreamTransport::~LibjingleStreamTransport() { 139 LibjingleStreamTransport::~LibjingleStreamTransport() {
140 DCHECK(event_handler_); 140 DCHECK(event_handler_);
141 event_handler_->OnTransportDeleted(this); 141 event_handler_->OnTransportDeleted(this);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 reconnect_timer_.Stop(); 372 reconnect_timer_.Stop();
373 373
374 // Notify the caller that ICE connection has failed - normally that will 374 // Notify the caller that ICE connection has failed - normally that will
375 // terminate Jingle connection (i.e. the transport will be destroyed). 375 // terminate Jingle connection (i.e. the transport will be destroyed).
376 event_handler_->OnTransportFailed(this); 376 event_handler_->OnTransportFailed(this);
377 return; 377 return;
378 } 378 }
379 --connect_attempts_left_; 379 --connect_attempts_left_;
380 380
381 // Restart ICE by resetting ICE password. 381 // Restart ICE by resetting ICE password.
382 ice_password_ = talk_base::CreateRandomString(cricket::ICE_PWD_LENGTH); 382 ice_password_ = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH);
383 channel_->SetIceCredentials(ice_username_fragment_, ice_password_); 383 channel_->SetIceCredentials(ice_username_fragment_, ice_password_);
384 } 384 }
385 385
386 void LibjingleStreamTransport::NotifyConnected( 386 void LibjingleStreamTransport::NotifyConnected(
387 scoped_ptr<net::StreamSocket> socket) { 387 scoped_ptr<net::StreamSocket> socket) {
388 DCHECK(!is_connected()); 388 DCHECK(!is_connected());
389 StreamTransport::ConnectedCallback callback = callback_; 389 StreamTransport::ConnectedCallback callback = callback_;
390 callback_.Reset(); 390 callback_.Reset();
391 callback.Run(socket.Pass()); 391 callback.Run(socket.Pass());
392 } 392 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 base::TimeDelta::FromSeconds(kJingleInfoUpdatePeriodSeconds)) { 468 base::TimeDelta::FromSeconds(kJingleInfoUpdatePeriodSeconds)) {
469 jingle_info_request_.reset(new JingleInfoRequest(signal_strategy_)); 469 jingle_info_request_.reset(new JingleInfoRequest(signal_strategy_));
470 jingle_info_request_->Send(base::Bind( 470 jingle_info_request_->Send(base::Bind(
471 &LibjingleTransportFactory::OnJingleInfo, base::Unretained(this))); 471 &LibjingleTransportFactory::OnJingleInfo, base::Unretained(this)));
472 } 472 }
473 } 473 }
474 474
475 void LibjingleTransportFactory::OnJingleInfo( 475 void LibjingleTransportFactory::OnJingleInfo(
476 const std::string& relay_token, 476 const std::string& relay_token,
477 const std::vector<std::string>& relay_hosts, 477 const std::vector<std::string>& relay_hosts,
478 const std::vector<talk_base::SocketAddress>& stun_hosts) { 478 const std::vector<rtc::SocketAddress>& stun_hosts) {
479 if (!relay_token.empty() && !relay_hosts.empty()) { 479 if (!relay_token.empty() && !relay_hosts.empty()) {
480 port_allocator_->SetRelayHosts(relay_hosts); 480 port_allocator_->SetRelayHosts(relay_hosts);
481 port_allocator_->SetRelayToken(relay_token); 481 port_allocator_->SetRelayToken(relay_token);
482 } 482 }
483 if (!stun_hosts.empty()) { 483 if (!stun_hosts.empty()) {
484 port_allocator_->SetStunHosts(stun_hosts); 484 port_allocator_->SetStunHosts(stun_hosts);
485 } 485 }
486 486
487 jingle_info_request_.reset(); 487 jingle_info_request_.reset();
488 if ((!relay_token.empty() && !relay_hosts.empty()) || !stun_hosts.empty()) 488 if ((!relay_token.empty() && !relay_hosts.empty()) || !stun_hosts.empty())
489 last_jingle_info_update_time_ = base::TimeTicks::Now(); 489 last_jingle_info_update_time_ = base::TimeTicks::Now();
490 490
491 while (!on_jingle_info_callbacks_.empty()) { 491 while (!on_jingle_info_callbacks_.empty()) {
492 on_jingle_info_callbacks_.begin()->Run(); 492 on_jingle_info_callbacks_.begin()->Run();
493 on_jingle_info_callbacks_.pop_front(); 493 on_jingle_info_callbacks_.pop_front();
494 } 494 }
495 } 495 }
496 496
497 } // namespace protocol 497 } // namespace protocol
498 } // namespace remoting 498 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/libjingle_transport_factory.h ('k') | remoting/protocol/message_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698