| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 DVLOG(1) << "Detected IP address change"; | 93 DVLOG(1) << "Detected IP address change"; |
| 94 OnNetworkEvent(); | 94 OnNetworkEvent(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Login::OnConnectionTypeChanged( | 97 void Login::OnConnectionTypeChanged( |
| 98 net::NetworkChangeNotifier::ConnectionType type) { | 98 net::NetworkChangeNotifier::ConnectionType type) { |
| 99 DVLOG(1) << "Detected connection type change"; | 99 DVLOG(1) << "Detected connection type change"; |
| 100 OnNetworkEvent(); | 100 OnNetworkEvent(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void Login::OnDNSChanged(unsigned detail) { | 103 void Login::OnDNSChanged() { |
| 104 DVLOG(1) << "Detected DNS change"; | 104 DVLOG(1) << "Detected DNS change"; |
| 105 OnNetworkEvent(); | 105 OnNetworkEvent(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void Login::OnNetworkEvent() { | 108 void Login::OnNetworkEvent() { |
| 109 // Reconnect in 1 to 9 seconds (vary the time a little to try to | 109 // Reconnect in 1 to 9 seconds (vary the time a little to try to |
| 110 // avoid spikey behavior on network hiccups). | 110 // avoid spikey behavior on network hiccups). |
| 111 reconnect_interval_ = base::TimeDelta::FromSeconds(base::RandInt(1, 9)); | 111 reconnect_interval_ = base::TimeDelta::FromSeconds(base::RandInt(1, 9)); |
| 112 TryReconnect(); | 112 TryReconnect(); |
| 113 delegate_->OnTransientDisconnection(); | 113 delegate_->OnTransientDisconnection(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 134 const base::TimeDelta kMaxReconnectInterval = | 134 const base::TimeDelta kMaxReconnectInterval = |
| 135 base::TimeDelta::FromMinutes(30); | 135 base::TimeDelta::FromMinutes(30); |
| 136 reconnect_interval_ *= 2; | 136 reconnect_interval_ *= 2; |
| 137 if (reconnect_interval_ > kMaxReconnectInterval) | 137 if (reconnect_interval_ > kMaxReconnectInterval) |
| 138 reconnect_interval_ = kMaxReconnectInterval; | 138 reconnect_interval_ = kMaxReconnectInterval; |
| 139 DVLOG(1) << "Reconnecting..."; | 139 DVLOG(1) << "Reconnecting..."; |
| 140 StartConnection(); | 140 StartConnection(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace notifier | 143 } // namespace notifier |
| OLD | NEW |