summaryrefslogtreecommitdiffstats
path: root/jingle
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 22:24:23 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 22:24:23 +0000
commitcc3d6f596df5fa5fa6258b69e947c8977ade7dc7 (patch)
tree45fb6e52c4bf49129dbc62e50c3e1b06418839cd /jingle
parenta21f65f36474d39b95b3b16aad15f6c7abbc8fb6 (diff)
downloadchromium_src-cc3d6f596df5fa5fa6258b69e947c8977ade7dc7.zip
chromium_src-cc3d6f596df5fa5fa6258b69e947c8977ade7dc7.tar.gz
chromium_src-cc3d6f596df5fa5fa6258b69e947c8977ade7dc7.tar.bz2
[Sync] Removed use of libjingle's sigslot in XmppConnectionGenerator
This is a speculative fix for the crash in the bug. BUG=58042 TEST=sync integration tests Review URL: http://codereview.chromium.org/4155004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63959 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r--jingle/notifier/communicator/single_login_attempt.cc29
-rw-r--r--jingle/notifier/communicator/single_login_attempt.h16
-rw-r--r--jingle/notifier/communicator/xmpp_connection_generator.cc20
-rw-r--r--jingle/notifier/communicator/xmpp_connection_generator.h29
4 files changed, 46 insertions, 48 deletions
diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc
index 4c361bd..2d2fbe0 100644
--- a/jingle/notifier/communicator/single_login_attempt.cc
+++ b/jingle/notifier/communicator/single_login_attempt.cc
@@ -9,6 +9,7 @@
#include "jingle/notifier/communicator/single_login_attempt.h"
+#include "base/compiler_specific.h"
#include "base/logging.h"
#include "jingle/notifier/communicator/connection_options.h"
#include "jingle/notifier/communicator/connection_settings.h"
@@ -30,18 +31,12 @@ namespace notifier {
SingleLoginAttempt::SingleLoginAttempt(LoginSettings* login_settings)
: login_settings_(login_settings),
connection_generator_(
+ ALLOW_THIS_IN_INITIALIZER_LIST(this),
login_settings_->host_resolver(),
&login_settings_->connection_options(),
login_settings_->try_ssltcp_first(),
login_settings_->server_list(),
login_settings_->server_count()) {
- connection_generator_.SignalExhaustedSettings.connect(
- this,
- &SingleLoginAttempt::OnAttemptedAllConnections);
- connection_generator_.SignalNewSettings.connect(
- this,
- &SingleLoginAttempt::DoLogin);
-
connection_generator_.StartGenerating();
}
@@ -97,16 +92,7 @@ void SingleLoginAttempt::OnError(buzz::XmppEngine::Error error, int subcode,
connection_generator_.UseNextConnection();
}
-void SingleLoginAttempt::OnAttemptedAllConnections(
- bool successfully_resolved_dns,
- int first_dns_error) {
- if (!successfully_resolved_dns)
- VLOG(1) << "Could not resolve DNS: " << first_dns_error;
- VLOG(1) << "Could not connect to any XMPP server";
- SignalNeedAutoReconnect();
-}
-
-void SingleLoginAttempt::DoLogin(
+void SingleLoginAttempt::OnNewSettings(
const ConnectionSettings& connection_settings) {
// TODO(akalin): Resolve any unresolved IPs, possibly through a
// proxy, instead of skipping them.
@@ -130,4 +116,13 @@ void SingleLoginAttempt::DoLogin(
new XmppConnection(client_settings, this, pre_xmpp_auth));
}
+void SingleLoginAttempt::OnExhaustedSettings(
+ bool successfully_resolved_dns,
+ int first_dns_error) {
+ if (!successfully_resolved_dns)
+ VLOG(1) << "Could not resolve DNS: " << first_dns_error;
+ VLOG(1) << "Could not connect to any XMPP server";
+ SignalNeedAutoReconnect();
+}
+
} // namespace notifier
diff --git a/jingle/notifier/communicator/single_login_attempt.h b/jingle/notifier/communicator/single_login_attempt.h
index d2c947b..ed8c7bf 100644
--- a/jingle/notifier/communicator/single_login_attempt.h
+++ b/jingle/notifier/communicator/single_login_attempt.h
@@ -21,26 +21,29 @@ namespace notifier {
class ConnectionSettings;
class LoginSettings;
-class XmppConnectionGenerator;
-class XmppConnection;
// Handles all of the aspects of a single login attempt (across multiple ip
// addresses) and maintainence. By containing this within one class, when
// another login attempt is made, this class will be disposed and all of the
// signalling for the previous login attempt will be cleaned up immediately.
class SingleLoginAttempt : public XmppConnection::Delegate,
- public sigslot::has_slots<> {
+ public XmppConnectionGenerator::Delegate {
public:
explicit SingleLoginAttempt(LoginSettings* login_settings);
virtual ~SingleLoginAttempt();
+ // XmppConnection::Delegate implementation.
virtual void OnConnect(base::WeakPtr<talk_base::Task> parent);
-
virtual void OnError(buzz::XmppEngine::Error error,
int error_subcode,
const buzz::XmlElement* stream_error);
+ // XmppConnectionGenerator::Delegate implementation.
+ virtual void OnNewSettings(const ConnectionSettings& new_settings);
+ virtual void OnExhaustedSettings(bool successfully_resolved_dns,
+ int first_dns_error);
+
// Typically handled by storing the redirect for 5 seconds, and setting it
// into LoginSettings, then creating a new SingleLoginAttempt, and doing
// StartConnection.
@@ -53,11 +56,6 @@ class SingleLoginAttempt : public XmppConnection::Delegate,
sigslot::signal1<base::WeakPtr<talk_base::Task> > SignalConnect;
private:
- void DoLogin(const ConnectionSettings& connection_settings);
-
- void OnAttemptedAllConnections(bool successfully_resolved_dns,
- int first_dns_error);
-
LoginSettings* login_settings_;
XmppConnectionGenerator connection_generator_;
scoped_ptr<XmppConnection> xmpp_connection_;
diff --git a/jingle/notifier/communicator/xmpp_connection_generator.cc b/jingle/notifier/communicator/xmpp_connection_generator.cc
index e62f176..d50d800 100644
--- a/jingle/notifier/communicator/xmpp_connection_generator.cc
+++ b/jingle/notifier/communicator/xmpp_connection_generator.cc
@@ -37,12 +37,14 @@
namespace notifier {
XmppConnectionGenerator::XmppConnectionGenerator(
+ Delegate* delegate,
net::HostResolver* host_resolver,
const ConnectionOptions* options,
bool try_ssltcp_first,
const ServerInformation* server_list,
int server_count)
- : host_resolver_(host_resolver),
+ : delegate_(delegate),
+ host_resolver_(host_resolver),
resolve_callback_(
ALLOW_THIS_IN_INITIALIZER_LIST(
NewCallback(this,
@@ -56,8 +58,9 @@ XmppConnectionGenerator::XmppConnectionGenerator(
successfully_resolved_dns_(false),
first_dns_error_(0),
options_(options) {
+ DCHECK(delegate_);
DCHECK(host_resolver);
- DCHECK(options);
+ DCHECK(options_);
DCHECK_GT(server_count_, 0);
for (int i = 0; i < server_count_; ++i) {
server_list_[i] = server_list[i];
@@ -96,7 +99,10 @@ void XmppConnectionGenerator::UseNextConnection() {
server_index_++;
if (server_index_ >= server_count_) {
// All out of possibilities.
- HandleExhaustedConnections();
+ VLOG(1) << "(" << buzz::XmppEngine::ERROR_SOCKET
+ << ", " << first_dns_error_ << ")";
+ delegate_->OnExhaustedSettings(
+ successfully_resolved_dns_, first_dns_error_);
return;
}
@@ -179,13 +185,7 @@ void XmppConnectionGenerator::UseCurrentConnection() {
<< " connection to " << settings->server().IPAsString()
<< ":" << settings->server().port();
- SignalNewSettings(*settings);
-}
-
-void XmppConnectionGenerator::HandleExhaustedConnections() {
- VLOG(1) << "(" << buzz::XmppEngine::ERROR_SOCKET
- << ", " << first_dns_error_ << ")";
- SignalExhaustedSettings(successfully_resolved_dns_, first_dns_error_);
+ delegate_->OnNewSettings(*settings);
}
} // namespace notifier
diff --git a/jingle/notifier/communicator/xmpp_connection_generator.h b/jingle/notifier/communicator/xmpp_connection_generator.h
index 0cb969c..07106a0 100644
--- a/jingle/notifier/communicator/xmpp_connection_generator.h
+++ b/jingle/notifier/communicator/xmpp_connection_generator.h
@@ -14,7 +14,6 @@
#include "net/base/host_resolver.h"
#include "net/base/net_log.h"
#include "talk/base/scoped_ptr.h"
-#include "talk/base/sigslot.h"
namespace talk_base {
struct ProxyInfo;
@@ -34,12 +33,24 @@ struct ServerInformation {
// Resolves dns names and iterates through the various ip address and transport
// combinations.
-class XmppConnectionGenerator : public sigslot::has_slots<> {
+class XmppConnectionGenerator {
public:
- // try_ssltcp_first indicates that SSLTCP is tried before XMPP. Used by tests.
- // server_list is the list of connections to attempt in priority order.
- // server_count is the number of items in the server list.
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ virtual void OnNewSettings(const ConnectionSettings& new_settings) = 0;
+ virtual void OnExhaustedSettings(bool successfully_resolved_dns,
+ int first_dns_error) = 0;
+ };
+
+ // Does not take ownership of |delegate|.
+ // |try_ssltcp_first| indicates that SSLTCP is tried before
+ // XMPP. Used by tests.
+ // |server_list| is the list of connections to attempt in priority order.
+ // |server_count| is the number of items in the server list.
XmppConnectionGenerator(
+ Delegate* delegate,
net::HostResolver* host_resolver,
const ConnectionOptions* options,
bool try_ssltcp_first,
@@ -54,17 +65,11 @@ class XmppConnectionGenerator : public sigslot::has_slots<> {
void UseNextConnection();
void UseCurrentConnection();
- sigslot::signal1<const ConnectionSettings&> SignalNewSettings;
-
- // SignalExhaustedSettings(bool successfully_resolved_dns,
- // int first_dns_error);
- sigslot::signal2<bool, int> SignalExhaustedSettings;
-
private:
void OnServerDNSResolved(int status);
void HandleServerDNSResolved(int status);
- void HandleExhaustedConnections();
+ Delegate* delegate_;
net::SingleRequestHostResolver host_resolver_;
scoped_ptr<net::CompletionCallback> resolve_callback_;
net::AddressList address_list_;