OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "jingle/notifier/communicator/login.h" | 5 #include "jingle/notifier/communicator/login.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 reconnect_timer_.Stop(); | 110 reconnect_timer_.Stop(); |
111 } | 111 } |
112 | 112 |
113 void Login::TryReconnect() { | 113 void Login::TryReconnect() { |
114 DCHECK_GT(reconnect_interval_.InSeconds(), 0); | 114 DCHECK_GT(reconnect_interval_.InSeconds(), 0); |
115 single_attempt_.reset(); | 115 single_attempt_.reset(); |
116 reconnect_timer_.Stop(); | 116 reconnect_timer_.Stop(); |
117 VLOG(1) << "Reconnecting in " | 117 VLOG(1) << "Reconnecting in " |
118 << reconnect_interval_.InSeconds() << " seconds"; | 118 << reconnect_interval_.InSeconds() << " seconds"; |
119 reconnect_timer_.Start( | 119 reconnect_timer_.Start( |
120 FROM_HERE, reconnect_interval_, this, &Login::DoReconnect); | 120 reconnect_interval_, this, &Login::DoReconnect); |
121 delegate_->OnDisconnect(); | 121 delegate_->OnDisconnect(); |
122 } | 122 } |
123 | 123 |
124 void Login::DoReconnect() { | 124 void Login::DoReconnect() { |
125 // Double reconnect time up to 30 minutes. | 125 // Double reconnect time up to 30 minutes. |
126 const base::TimeDelta kMaxReconnectInterval = | 126 const base::TimeDelta kMaxReconnectInterval = |
127 base::TimeDelta::FromMinutes(30); | 127 base::TimeDelta::FromMinutes(30); |
128 reconnect_interval_ *= 2; | 128 reconnect_interval_ *= 2; |
129 if (reconnect_interval_ > kMaxReconnectInterval) | 129 if (reconnect_interval_ > kMaxReconnectInterval) |
130 reconnect_interval_ = kMaxReconnectInterval; | 130 reconnect_interval_ = kMaxReconnectInterval; |
131 VLOG(1) << "Reconnecting..."; | 131 VLOG(1) << "Reconnecting..."; |
132 StartConnection(); | 132 StartConnection(); |
133 } | 133 } |
134 | 134 |
135 } // namespace notifier | 135 } // namespace notifier |
OLD | NEW |