| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import org.chromium.chromoting.jni.JniInterface; | 7 import org.chromium.chromoting.jni.JniInterface; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * This class manages making a connection to a host, with logic for reloading th
e host list and | 10 * This class manages making a connection to a host, with logic for reloading th
e host list and |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return host.jabberId.isEmpty() || host.publicKey.isEmpty(); | 58 return host.jabberId.isEmpty() || host.publicKey.isEmpty(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 private void reloadHostListAndConnect() { | 61 private void reloadHostListAndConnect() { |
| 62 mHostListLoader.retrieveHostList(mAuthToken, this); | 62 mHostListLoader.retrieveHostList(mAuthToken, this); |
| 63 } | 63 } |
| 64 | 64 |
| 65 @Override | 65 @Override |
| 66 public void onConnectionState(JniInterface.ConnectionListener.State state, | 66 public void onConnectionState(JniInterface.ConnectionListener.State state, |
| 67 JniInterface.ConnectionListener.Error error) { | 67 JniInterface.ConnectionListener.Error error) { |
| 68 if (state == JniInterface.ConnectionListener.State.FAILED && | 68 if (state == JniInterface.ConnectionListener.State.FAILED |
| 69 error == JniInterface.ConnectionListener.Error.PEER_IS_OFFLINE)
{ | 69 && error == JniInterface.ConnectionListener.Error.PEER_IS_OFFLIN
E) { |
| 70 // The host is offline, which may mean the JID is out of date, so re
fresh the host list | 70 // The host is offline, which may mean the JID is out of date, so re
fresh the host list |
| 71 // and try to connect again. | 71 // and try to connect again. |
| 72 reloadHostListAndConnect(); | 72 reloadHostListAndConnect(); |
| 73 } else { | 73 } else { |
| 74 // Pass the state/error back to the caller. | 74 // Pass the state/error back to the caller. |
| 75 mConnectionCallback.onConnectionState(state, error); | 75 mConnectionCallback.onConnectionState(state, error); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 @Override | 79 @Override |
| (...skipping 28 matching lines...) Expand all Loading... |
| 108 // Connection failed and reloading the host list also failed, so report
the connection | 108 // Connection failed and reloading the host list also failed, so report
the connection |
| 109 // error. | 109 // error. |
| 110 mConnectionCallback.onConnectionState(JniInterface.ConnectionListener.St
ate.FAILED, | 110 mConnectionCallback.onConnectionState(JniInterface.ConnectionListener.St
ate.FAILED, |
| 111 JniInterface.ConnectionListener.Error.PEER_IS_OFFLINE); | 111 JniInterface.ConnectionListener.Error.PEER_IS_OFFLINE); |
| 112 | 112 |
| 113 // Notify the caller that the host list failed to load, so the UI is upd
ated accordingly. | 113 // Notify the caller that the host list failed to load, so the UI is upd
ated accordingly. |
| 114 // The currently-displayed host list is not likely to be valid any more. | 114 // The currently-displayed host list is not likely to be valid any more. |
| 115 mHostListCallback.onError(error); | 115 mHostListCallback.onError(error); |
| 116 } | 116 } |
| 117 } | 117 } |
| OLD | NEW |