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

Unified Diff: remoting/protocol/libjingle_transport_factory.cc

Issue 889043002: Fix LibjingleTransport to notify about route changes only when connected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@policy_init_me2me
Patch Set: Created 5 years, 11 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 fe8a0769c25d4d1fd6eebce755e4a2e2e33c8e91..2c68d455b9cf37251ecc6524b6a35c7d2ca88340 100644
--- a/remoting/protocol/libjingle_transport_factory.cc
+++ b/remoting/protocol/libjingle_transport_factory.cc
@@ -86,6 +86,8 @@ class LibjingleTransport
// socket is destroyed.
void OnChannelDestroyed();
+ void NotifyRouteChanged();
+
// Tries to connect by restarting ICE. Called by |reconnect_timer_|.
void TryReconnect();
@@ -258,6 +260,44 @@ void LibjingleTransport::OnCandidateReady(
void LibjingleTransport::OnRouteChange(
cricket::TransportChannel* channel,
const cricket::Candidate& candidate) {
+ // Ignore notifications if the channel is not writable.
+ if (channel_->writable())
+ NotifyRouteChanged();
+}
+
+void LibjingleTransport::OnWritableState(
+ cricket::TransportChannel* channel) {
+ DCHECK_EQ(channel, channel_.get());
+
+ if (channel->writable()) {
+ 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();
+
+ // Route change notifications are ignored when the |channel_| is not
+ // writable. Notify the event handler about the current route once the
+ // channel is writable.
+ NotifyRouteChanged();
+ } else if (!channel->writable() && channel_was_writable_) {
+ reconnect_timer_.Reset();
+ TryReconnect();
+ }
+}
+
+void LibjingleTransport::OnChannelDestroyed() {
+ if (is_connected()) {
+ // The connection socket is being deleted, so delete the transport too.
+ delete this;
+ }
+}
+
+void LibjingleTransport::NotifyRouteChanged() {
TransportRoute route;
DCHECK(channel_->best_connection());
@@ -276,7 +316,7 @@ void LibjingleTransport::OnRouteChange(
CandidateTypeToTransportRouteType(connection->remote_candidate().type()));
if (!jingle_glue::SocketAddressToIPEndPoint(
- candidate.address(), &route.remote_address)) {
+ connection->remote_candidate().address(), &route.remote_address)) {
LOG(FATAL) << "Failed to convert peer IP address.";
}
@@ -290,33 +330,6 @@ void LibjingleTransport::OnRouteChange(
event_handler_->OnTransportRouteChange(this, route);
}
-void LibjingleTransport::OnWritableState(
- cricket::TransportChannel* channel) {
- DCHECK_EQ(channel, channel_.get());
-
- if (channel->writable()) {
- 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_) {
- reconnect_timer_.Reset();
- TryReconnect();
- }
-}
-
-void LibjingleTransport::OnChannelDestroyed() {
- if (is_connected()) {
- // The connection socket is being deleted, so delete the transport too.
- delete this;
- }
-}
-
void LibjingleTransport::TryReconnect() {
DCHECK(!channel_->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