OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 29 matching lines...) Expand all Loading... |
40 bool try_ssltcp_first) | 40 bool try_ssltcp_first) |
41 : delegate_(delegate), | 41 : delegate_(delegate), |
42 login_settings_(new LoginSettings(user_settings, | 42 login_settings_(new LoginSettings(user_settings, |
43 options, | 43 options, |
44 host_resolver, | 44 host_resolver, |
45 cert_verifier, | 45 cert_verifier, |
46 server_list, | 46 server_list, |
47 server_count, | 47 server_count, |
48 try_ssltcp_first)), | 48 try_ssltcp_first)), |
49 redirect_port_(0) { | 49 redirect_port_(0) { |
50 net::NetworkChangeNotifier::AddObserver(this); | 50 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
51 ResetReconnectState(); | 51 ResetReconnectState(); |
52 } | 52 } |
53 | 53 |
54 Login::~Login() { | 54 Login::~Login() { |
55 net::NetworkChangeNotifier::RemoveObserver(this); | 55 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
56 } | 56 } |
57 | 57 |
58 void Login::StartConnection() { | 58 void Login::StartConnection() { |
59 // If there is a server redirect, use it. | 59 // If there is a server redirect, use it. |
60 if (base::Time::Now() < | 60 if (base::Time::Now() < |
61 (redirect_time_ + | 61 (redirect_time_ + |
62 base::TimeDelta::FromMinutes(kRedirectTimeoutMinutes))) { | 62 base::TimeDelta::FromMinutes(kRedirectTimeoutMinutes))) { |
63 // Override server/port with redirect values. | 63 // Override server/port with redirect values. |
64 DCHECK_NE(redirect_port_, 0); | 64 DCHECK_NE(redirect_port_, 0); |
65 net::HostPortPair server_override(redirect_server_, redirect_port_); | 65 net::HostPortPair server_override(redirect_server_, redirect_port_); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 const base::TimeDelta kMaxReconnectInterval = | 123 const base::TimeDelta kMaxReconnectInterval = |
124 base::TimeDelta::FromMinutes(30); | 124 base::TimeDelta::FromMinutes(30); |
125 reconnect_interval_ *= 2; | 125 reconnect_interval_ *= 2; |
126 if (reconnect_interval_ > kMaxReconnectInterval) | 126 if (reconnect_interval_ > kMaxReconnectInterval) |
127 reconnect_interval_ = kMaxReconnectInterval; | 127 reconnect_interval_ = kMaxReconnectInterval; |
128 VLOG(1) << "Reconnecting..."; | 128 VLOG(1) << "Reconnecting..."; |
129 StartConnection(); | 129 StartConnection(); |
130 } | 130 } |
131 | 131 |
132 } // namespace notifier | 132 } // namespace notifier |
OLD | NEW |