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 <string> | 5 #include <string> |
6 | 6 |
7 #include "jingle/notifier/communicator/login.h" | 7 #include "jingle/notifier/communicator/login.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "jingle/notifier/communicator/connection_options.h" | 12 #include "jingle/notifier/communicator/connection_options.h" |
13 #include "jingle/notifier/communicator/login_settings.h" | 13 #include "jingle/notifier/communicator/login_settings.h" |
14 #include "jingle/notifier/communicator/product_info.h" | |
15 #include "jingle/notifier/communicator/single_login_attempt.h" | 14 #include "jingle/notifier/communicator/single_login_attempt.h" |
16 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
17 #include "talk/base/common.h" | 16 #include "talk/base/common.h" |
18 #include "talk/base/firewallsocketserver.h" | 17 #include "talk/base/firewallsocketserver.h" |
19 #include "talk/base/logging.h" | 18 #include "talk/base/logging.h" |
20 #include "talk/base/physicalsocketserver.h" | 19 #include "talk/base/physicalsocketserver.h" |
21 #include "talk/base/taskrunner.h" | 20 #include "talk/base/taskrunner.h" |
22 #include "talk/xmllite/xmlelement.h" | 21 #include "talk/xmllite/xmlelement.h" |
23 #include "talk/xmpp/asyncsocket.h" | 22 #include "talk/xmpp/asyncsocket.h" |
24 #include "talk/xmpp/prexmppauth.h" | 23 #include "talk/xmpp/prexmppauth.h" |
25 #include "talk/xmpp/xmppclient.h" | 24 #include "talk/xmpp/xmppclient.h" |
26 #include "talk/xmpp/xmppclientsettings.h" | 25 #include "talk/xmpp/xmppclientsettings.h" |
27 #include "talk/xmpp/xmppengine.h" | 26 #include "talk/xmpp/xmppengine.h" |
28 | 27 |
29 namespace notifier { | 28 namespace notifier { |
30 | 29 |
31 // Redirect valid for 5 minutes. | 30 // Redirect valid for 5 minutes. |
32 static const int kRedirectTimeoutMinutes = 5; | 31 static const int kRedirectTimeoutMinutes = 5; |
33 | 32 |
34 Login::Login(talk_base::TaskParent* parent, | 33 Login::Login(talk_base::TaskParent* parent, |
35 bool use_chrome_async_socket, | |
36 const buzz::XmppClientSettings& user_settings, | 34 const buzz::XmppClientSettings& user_settings, |
37 const ConnectionOptions& options, | 35 const ConnectionOptions& options, |
38 std::string lang, | 36 std::string lang, |
39 net::HostResolver* host_resolver, | 37 net::HostResolver* host_resolver, |
40 ServerInformation* server_list, | 38 ServerInformation* server_list, |
41 int server_count, | 39 int server_count, |
42 talk_base::FirewallManager* firewall, | 40 talk_base::FirewallManager* firewall, |
43 bool try_ssltcp_first, | 41 bool try_ssltcp_first, |
44 bool proxy_only) | 42 bool proxy_only) |
45 : parent_(parent), | 43 : parent_(parent), |
46 use_chrome_async_socket_(use_chrome_async_socket), | |
47 login_settings_(new LoginSettings(user_settings, | 44 login_settings_(new LoginSettings(user_settings, |
48 options, | 45 options, |
49 lang, | 46 lang, |
50 host_resolver, | 47 host_resolver, |
51 server_list, | 48 server_list, |
52 server_count, | 49 server_count, |
53 firewall, | 50 firewall, |
54 try_ssltcp_first, | 51 try_ssltcp_first, |
55 proxy_only)), | 52 proxy_only)), |
56 state_(STATE_DISCONNECTED), | 53 state_(STATE_DISCONNECTED), |
(...skipping 19 matching lines...) Expand all Loading... |
76 login_settings_->set_server_override(server_override); | 73 login_settings_->set_server_override(server_override); |
77 } else { | 74 } else { |
78 login_settings_->clear_server_override(); | 75 login_settings_->clear_server_override(); |
79 } | 76 } |
80 | 77 |
81 Disconnect(); | 78 Disconnect(); |
82 | 79 |
83 LOG(INFO) << "Starting connection..."; | 80 LOG(INFO) << "Starting connection..."; |
84 | 81 |
85 single_attempt_ = new SingleLoginAttempt(parent_, | 82 single_attempt_ = new SingleLoginAttempt(parent_, |
86 login_settings_.get(), | 83 login_settings_.get()); |
87 use_chrome_async_socket_, | |
88 true); | |
89 | 84 |
90 // Do the signaling hook-ups. | 85 // Do the signaling hook-ups. |
91 single_attempt_->SignalUnexpectedDisconnect.connect( | 86 single_attempt_->SignalUnexpectedDisconnect.connect( |
92 this, | 87 this, |
93 &Login::TryReconnect); | 88 &Login::TryReconnect); |
94 single_attempt_->SignalNeedAutoReconnect.connect( | 89 single_attempt_->SignalNeedAutoReconnect.connect( |
95 this, | 90 this, |
96 &Login::TryReconnect); | 91 &Login::TryReconnect); |
97 single_attempt_->SignalLoginFailure.connect(this, &Login::OnLoginFailure); | 92 single_attempt_->SignalLoginFailure.connect(this, &Login::OnLoginFailure); |
98 single_attempt_->SignalLogoff.connect( | 93 single_attempt_->SignalLogoff.connect( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 base::TimeDelta::FromMinutes(30); | 181 base::TimeDelta::FromMinutes(30); |
187 reconnect_interval_ *= 2; | 182 reconnect_interval_ *= 2; |
188 if (reconnect_interval_ > kMaxReconnectInterval) { | 183 if (reconnect_interval_ > kMaxReconnectInterval) { |
189 reconnect_interval_ = kMaxReconnectInterval; | 184 reconnect_interval_ = kMaxReconnectInterval; |
190 } | 185 } |
191 LOG(INFO) << "Reconnecting..."; | 186 LOG(INFO) << "Reconnecting..."; |
192 StartConnection(); | 187 StartConnection(); |
193 } | 188 } |
194 | 189 |
195 } // namespace notifier | 190 } // namespace notifier |
OLD | NEW |