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

Unified Diff: remoting/protocol/libjingle_transport_factory.cc

Issue 587943002: Don't start PseudoTCP until underlying transport is connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/libjingle_transport_factory.cc
diff --git a/remoting/protocol/libjingle_transport_factory.cc b/remoting/protocol/libjingle_transport_factory.cc
index 61ed3eafeba591bd021adca6412aff14a7b80db1..404415058fdd170f8dddb5225a30173cfe9f5b11 100644
--- a/remoting/protocol/libjingle_transport_factory.cc
+++ b/remoting/protocol/libjingle_transport_factory.cc
@@ -55,6 +55,7 @@ class LibjingleTransport
private:
void DoStart();
+ void NotifyConnected();
// Signal handlers for cricket::TransportChannel.
void OnRequestSignaling(cricket::TransportChannelImpl* channel);
@@ -88,12 +89,13 @@ class LibjingleTransport
int connect_attempts_left_;
base::RepeatingTimer<LibjingleTransport> reconnect_timer_;
+ base::WeakPtrFactory<LibjingleTransport> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(LibjingleTransport);
};
-LibjingleTransport::LibjingleTransport(
- cricket::PortAllocator* port_allocator,
- const NetworkSettings& network_settings)
+LibjingleTransport::LibjingleTransport(cricket::PortAllocator* port_allocator,
+ const NetworkSettings& network_settings)
: port_allocator_(port_allocator),
network_settings_(network_settings),
event_handler_(NULL),
@@ -102,7 +104,8 @@ LibjingleTransport::LibjingleTransport(
ice_password_(rtc::CreateRandomString(cricket::ICE_PWD_LENGTH)),
can_start_(false),
channel_was_writable_(false),
- connect_attempts_left_(kMaxReconnectAttempts) {
+ connect_attempts_left_(kMaxReconnectAttempts),
+ weak_factory_(this) {
DCHECK(!ice_username_fragment_.empty());
DCHECK(!ice_password_.empty());
}
@@ -180,7 +183,9 @@ void LibjingleTransport::DoStart() {
reconnect_timer_.Start(
FROM_HERE, base::TimeDelta::FromSeconds(kReconnectDelaySeconds),
this, &LibjingleTransport::TryReconnect);
+}
+void LibjingleTransport::NotifyConnected() {
// Create net::Socket adapter for the P2PTransportChannel.
scoped_ptr<jingle_glue::TransportChannelSocketAdapter> socket(
new jingle_glue::TransportChannelSocketAdapter(channel_.get()));
@@ -269,7 +274,13 @@ void LibjingleTransport::OnWritableState(
DCHECK_EQ(channel, channel_.get());
if (channel->writable()) {
- channel_was_writable_ = true;
+ if (!channel_was_writable_) {
+ channel_was_writable_ = true;
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&LibjingleTransport::NotifyConnected,
+ weak_factory_.GetWeakPtr()));
+ }
connect_attempts_left_ = kMaxReconnectAttempts;
reconnect_timer_.Stop();
} else if (!channel->writable() && channel_was_writable_) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698