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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/SessionConnector.java

Issue 926263002: Android Chromoting: Don't auto-reconnect if connection was established. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/android/java/src/org/chromium/chromoting/SessionConnector.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/SessionConnector.java b/remoting/android/java/src/org/chromium/chromoting/SessionConnector.java
index 4d52ef683c98f5b4fb0bc97757a6c08ae79d7095..20fad2595a3481a1cc3a02e4b30a4f6d8e7eede9 100644
--- a/remoting/android/java/src/org/chromium/chromoting/SessionConnector.java
+++ b/remoting/android/java/src/org/chromium/chromoting/SessionConnector.java
@@ -25,6 +25,12 @@ public class SessionConnector implements JniInterface.ConnectionListener,
private String mHostJabberId;
/**
+ * Tracks whether the connection has been established. Auto-reloading and reconnecting should
+ * only happen if connection has not yet occurred.
+ */
+ private boolean mConnected;
+
+ /**
* @param connectionCallback Object to be notified on connection success/failure.
* @param hostListCallback Object to be notified whenever the host list is reloaded.
* @param hostListLoader The object used for reloading the host list.
@@ -65,7 +71,10 @@ public class SessionConnector implements JniInterface.ConnectionListener,
@Override
public void onConnectionState(JniInterface.ConnectionListener.State state,
JniInterface.ConnectionListener.Error error) {
- if (state == JniInterface.ConnectionListener.State.FAILED
+ boolean connected = mConnected;
+ mConnected = (state == JniInterface.ConnectionListener.State.CONNECTED);
+
+ if (!connected && state == JniInterface.ConnectionListener.State.FAILED
&& error == JniInterface.ConnectionListener.Error.PEER_IS_OFFLINE) {
// The host is offline, which may mean the JID is out of date, so refresh the host list
// and try to connect again.
« 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