Skip to content

Commit c01918a

Browse files
author
Brian Chen
committed
update comments
1 parent 940316c commit c01918a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/OnlineStateTracker.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
* <p>In particular, when the client is trying to connect to the backend, we allow up to
3333
* MAX_WATCH_STREAM_FAILURES within ONLINE_STATE_TIMEOUT_MS for a connection to succeed. If we have
3434
* too many failures or the timeout elapses, then we set the OnlineState to OFFLINE, and the client
35-
* will behave as if it is offline (get() calls will return cached data, etc.).
35+
* will behave as if it is offline (get() calls will return cached data, etc.). The client will
36+
* continue to attempt reconnecting, restarting the underlying connection every
37+
* CONNECTIVITY_ATTEMPT_TIMEOUT_MS.
3638
*/
3739
class OnlineStateTracker {
3840

@@ -149,7 +151,7 @@ void handleWatchStreamFailure(Status status) {
149151
hardAssert(this.onlineStateTimer == null, "onlineStateTimer must be null");
150152
} else {
151153
watchStreamFailures++;
152-
clearConnectivityAttemptTimer();
154+
clearTimers();
153155
if (watchStreamFailures >= MAX_WATCH_STREAM_FAILURES) {
154156
logClientOfflineWarningIfNecessary(
155157
String.format(
@@ -169,7 +171,7 @@ void handleWatchStreamFailure(Status status) {
169171
* it must not be used in place of handleWatchStreamStart() and handleWatchStreamFailure().
170172
*/
171173
void updateState(OnlineState newState) {
172-
clearConnectivityAttemptTimer();
174+
clearTimers();
173175
watchStreamFailures = 0;
174176

175177
if (newState == OnlineState.ONLINE) {
@@ -205,8 +207,8 @@ private void logClientOfflineWarningIfNecessary(String reason) {
205207
}
206208
}
207209

208-
/** Clears the connectivity attempt timer that has been passed in. */
209-
private void clearConnectivityAttemptTimer() {
210+
/** Clears the OnlineStateTimer and the passed in ConnectivityAttemptTimer. */
211+
private void clearTimers() {
210212
if (connectivityAttemptTimer != null) {
211213
connectivityAttemptTimer.cancel();
212214
connectivityAttemptTimer = null;
@@ -217,7 +219,7 @@ private void clearConnectivityAttemptTimer() {
217219
}
218220
}
219221

220-
/** Set the connectivity attempt timer to track. */
222+
/** Sets the connectivity attempt timer to track. */
221223
void setConnectivityAttemptTimer(DelayedTask connectivityAttemptTimer) {
222224
this.connectivityAttemptTimer = connectivityAttemptTimer;
223225
}

0 commit comments

Comments
 (0)