summaryrefslogtreecommitdiffstats
path: root/jingle
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-02 19:34:15 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-02 19:34:15 +0000
commitd6f26a3269d09ed48de1afc90bd2ed3f3ad81cd1 (patch)
tree1010fe6eeb88ba3fa0e7efdba01cb01d3be25807 /jingle
parenteae2a829891e7e8a186aa0ea6a4fbae8ea921b99 (diff)
downloadchromium_src-d6f26a3269d09ed48de1afc90bd2ed3f3ad81cd1.zip
chromium_src-d6f26a3269d09ed48de1afc90bd2ed3f3ad81cd1.tar.gz
chromium_src-d6f26a3269d09ed48de1afc90bd2ed3f3ad81cd1.tar.bz2
[Sync] Removed more uses of libjingle's sigslot
Another speculative fix for the crash in the bug. BUG=58042 TEST=sync integration tests Review URL: http://codereview.chromium.org/4275001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r--jingle/notifier/communicator/login.cc31
-rw-r--r--jingle/notifier/communicator/login.h31
-rw-r--r--jingle/notifier/communicator/single_login_attempt.cc10
-rw-r--r--jingle/notifier/communicator/single_login_attempt.h27
-rw-r--r--jingle/notifier/listener/mediator_thread_impl.cc9
-rw-r--r--jingle/notifier/listener/mediator_thread_impl.h25
-rw-r--r--jingle/notifier/listener/talk_mediator_impl.h1
7 files changed, 64 insertions, 70 deletions
diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc
index c12ca06..33a2124 100644
--- a/jingle/notifier/communicator/login.cc
+++ b/jingle/notifier/communicator/login.cc
@@ -30,13 +30,15 @@ namespace notifier {
// Redirect valid for 5 minutes.
static const int kRedirectTimeoutMinutes = 5;
-Login::Login(const buzz::XmppClientSettings& user_settings,
+Login::Login(Delegate* delegate,
+ const buzz::XmppClientSettings& user_settings,
const ConnectionOptions& options,
net::HostResolver* host_resolver,
ServerInformation* server_list,
int server_count,
bool try_ssltcp_first)
- : login_settings_(new LoginSettings(user_settings,
+ : delegate_(delegate),
+ login_settings_(new LoginSettings(user_settings,
options,
host_resolver,
server_list,
@@ -66,16 +68,16 @@ void Login::StartConnection() {
VLOG(1) << "Starting connection...";
- single_attempt_.reset(new SingleLoginAttempt(login_settings_.get()));
+ single_attempt_.reset(new SingleLoginAttempt(login_settings_.get(), this));
+}
+
+void Login::OnConnect(base::WeakPtr<talk_base::Task> base_task) {
+ ResetReconnectState();
+ delegate_->OnConnect(base_task);
+}
- // Do the signaling hook-ups.
- single_attempt_->SignalNeedAutoReconnect.connect(
- this,
- &Login::TryReconnect);
- single_attempt_->SignalRedirect.connect(this, &Login::OnRedirect);
- single_attempt_->SignalConnect.connect(
- this,
- &Login::OnConnect);
+void Login::OnNeedReconnect() {
+ TryReconnect();
}
void Login::OnRedirect(const std::string& redirect_server, int redirect_port) {
@@ -89,11 +91,6 @@ void Login::OnRedirect(const std::string& redirect_server, int redirect_port) {
StartConnection();
}
-void Login::OnConnect(base::WeakPtr<talk_base::Task> base_task) {
- ResetReconnectState();
- SignalConnect(base_task);
-}
-
void Login::OnIPAddressChanged() {
VLOG(1) << "Detected IP address change";
// Reconnect in 1 to 9 seconds (vary the time a little to try to
@@ -116,7 +113,7 @@ void Login::TryReconnect() {
<< reconnect_interval_.InSeconds() << " seconds";
reconnect_timer_.Start(
reconnect_interval_, this, &Login::DoReconnect);
- SignalDisconnect();
+ delegate_->OnDisconnect();
}
void Login::DoReconnect() {
diff --git a/jingle/notifier/communicator/login.h b/jingle/notifier/communicator/login.h
index b66ee7b..d80de6c 100644
--- a/jingle/notifier/communicator/login.h
+++ b/jingle/notifier/communicator/login.h
@@ -11,9 +11,8 @@
#include "base/time.h"
#include "base/timer.h"
#include "base/weak_ptr.h"
+#include "jingle/notifier/communicator/single_login_attempt.h"
#include "net/base/network_change_notifier.h"
-#include "talk/base/proxyinfo.h"
-#include "talk/base/sigslot.h"
#include "talk/xmpp/xmppengine.h"
namespace buzz {
@@ -36,16 +35,25 @@ namespace notifier {
class ConnectionOptions;
class LoginSettings;
struct ServerInformation;
-class SingleLoginAttempt;
// Does the login, keeps it alive (with refreshing cookies and reattempting
// login when disconnected), figures out what actions to take on the various
// errors that may occur.
class Login : public net::NetworkChangeNotifier::Observer,
- public sigslot::has_slots<> {
+ public SingleLoginAttempt::Delegate {
public:
- // firewall may be NULL.
- Login(const buzz::XmppClientSettings& user_settings,
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ virtual void OnConnect(base::WeakPtr<talk_base::Task> base_task) = 0;
+ virtual void OnDisconnect() = 0;
+ };
+
+ // Does not take ownership of |delegate|, |host_resolver|, or
+ // |server_list|, none of which may be NULL.
+ Login(Delegate* delegate,
+ const buzz::XmppClientSettings& user_settings,
const ConnectionOptions& options,
net::HostResolver* host_resolver,
ServerInformation* server_list,
@@ -58,13 +66,14 @@ class Login : public net::NetworkChangeNotifier::Observer,
// net::NetworkChangeNotifier::Observer implementation.
virtual void OnIPAddressChanged();
- sigslot::signal1<base::WeakPtr<talk_base::Task> > SignalConnect;
- sigslot::signal0<> SignalDisconnect;
+ // SingleLoginAttempt::Delegate implementation.
+ virtual void OnConnect(base::WeakPtr<talk_base::Task> base_task);
+ virtual void OnNeedReconnect();
+ virtual void OnRedirect(const std::string& redirect_server,
+ int redirect_port);
private:
void OnLogoff();
- void OnRedirect(const std::string& redirect_server, int redirect_port);
- void OnConnect(base::WeakPtr<talk_base::Task> parent);
// Stops any existing reconnect timer and sets an initial reconnect
// interval.
@@ -78,7 +87,7 @@ class Login : public net::NetworkChangeNotifier::Observer,
// reconnection.
void DoReconnect();
- talk_base::TaskParent* parent_;
+ Delegate* delegate_;
scoped_ptr<LoginSettings> login_settings_;
scoped_ptr<SingleLoginAttempt> single_attempt_;
diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc
index 2d2fbe0..548174b 100644
--- a/jingle/notifier/communicator/single_login_attempt.cc
+++ b/jingle/notifier/communicator/single_login_attempt.cc
@@ -28,8 +28,10 @@ class NetLog;
namespace notifier {
-SingleLoginAttempt::SingleLoginAttempt(LoginSettings* login_settings)
+SingleLoginAttempt::SingleLoginAttempt(LoginSettings* login_settings,
+ Delegate* delegate)
: login_settings_(login_settings),
+ delegate_(delegate),
connection_generator_(
ALLOW_THIS_IN_INITIALIZER_LIST(this),
login_settings_->host_resolver(),
@@ -43,7 +45,7 @@ SingleLoginAttempt::SingleLoginAttempt(LoginSettings* login_settings)
SingleLoginAttempt::~SingleLoginAttempt() {}
void SingleLoginAttempt::OnConnect(base::WeakPtr<talk_base::Task> base_task) {
- SignalConnect(base_task);
+ delegate_->OnConnect(base_task);
}
void SingleLoginAttempt::OnError(buzz::XmppEngine::Error error, int subcode,
@@ -81,7 +83,7 @@ void SingleLoginAttempt::OnError(buzz::XmppEngine::Error error, int subcode,
if (redirect_port == 0) {
redirect_port = kDefaultXmppPort;
}
- SignalRedirect(redirect_server, redirect_port);
+ delegate_->OnRedirect(redirect_server, redirect_port);
// May be deleted at this point.
return;
}
@@ -122,7 +124,7 @@ void SingleLoginAttempt::OnExhaustedSettings(
if (!successfully_resolved_dns)
VLOG(1) << "Could not resolve DNS: " << first_dns_error;
VLOG(1) << "Could not connect to any XMPP server";
- SignalNeedAutoReconnect();
+ delegate_->OnNeedReconnect();
}
} // namespace notifier
diff --git a/jingle/notifier/communicator/single_login_attempt.h b/jingle/notifier/communicator/single_login_attempt.h
index ed8c7bf..6c33c51 100644
--- a/jingle/notifier/communicator/single_login_attempt.h
+++ b/jingle/notifier/communicator/single_login_attempt.h
@@ -10,7 +10,6 @@
#include "base/scoped_ptr.h"
#include "jingle/notifier/base/xmpp_connection.h"
#include "jingle/notifier/communicator/xmpp_connection_generator.h"
-#include "talk/base/sigslot.h"
#include "talk/xmpp/xmppengine.h"
namespace talk_base {
@@ -29,7 +28,19 @@ class LoginSettings;
class SingleLoginAttempt : public XmppConnection::Delegate,
public XmppConnectionGenerator::Delegate {
public:
- explicit SingleLoginAttempt(LoginSettings* login_settings);
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ virtual void OnConnect(base::WeakPtr<talk_base::Task> base_task) = 0;
+ virtual void OnNeedReconnect() = 0;
+ virtual void OnRedirect(const std::string& redirect_server,
+ int redirect_port) = 0;
+ };
+
+ // Does not take ownership of |login_settings| or |delegate|.
+ // Neither may be NULL.
+ SingleLoginAttempt(LoginSettings* login_settings, Delegate* delegate);
virtual ~SingleLoginAttempt();
@@ -44,19 +55,9 @@ class SingleLoginAttempt : public XmppConnection::Delegate,
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.
- //
- // SignalRedirect(const std::string& redirect_server, int redirect_port);
- sigslot::signal2<const std::string&, int> SignalRedirect;
-
- sigslot::signal0<> SignalNeedAutoReconnect;
-
- sigslot::signal1<base::WeakPtr<talk_base::Task> > SignalConnect;
-
private:
LoginSettings* login_settings_;
+ Delegate* delegate_;
XmppConnectionGenerator connection_generator_;
scoped_ptr<XmppConnection> xmpp_connection_;
diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc
index 9782c55..fb3f709 100644
--- a/jingle/notifier/listener/mediator_thread_impl.cc
+++ b/jingle/notifier/listener/mediator_thread_impl.cc
@@ -16,7 +16,6 @@
#include "jingle/notifier/listener/subscribe_task.h"
#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
-#include "talk/xmpp/xmppclient.h"
#include "talk/xmpp/xmppclientsettings.h"
// We manage the lifetime of notifier::MediatorThreadImpl ourselves.
@@ -150,17 +149,13 @@ void MediatorThreadImpl::DoLogin(
// Autodetect proxy is on by default.
notifier::ConnectionOptions options;
- login_.reset(new notifier::Login(settings,
+ login_.reset(new notifier::Login(this,
+ settings,
options,
host_resolver_.get(),
server_list,
server_list_count,
notifier_options_.try_ssltcp_first));
-
- login_->SignalConnect.connect(
- this, &MediatorThreadImpl::OnConnect);
- login_->SignalDisconnect.connect(
- this, &MediatorThreadImpl::OnDisconnect);
login_->StartConnection();
}
diff --git a/jingle/notifier/listener/mediator_thread_impl.h b/jingle/notifier/listener/mediator_thread_impl.h
index 32a49e8..17efcad 100644
--- a/jingle/notifier/listener/mediator_thread_impl.h
+++ b/jingle/notifier/listener/mediator_thread_impl.h
@@ -28,16 +28,16 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/thread.h"
+#include "base/weak_ptr.h"
#include "jingle/notifier/base/notifier_options.h"
#include "jingle/notifier/communicator/login.h"
#include "jingle/notifier/listener/mediator_thread.h"
#include "talk/base/sigslot.h"
-#include "talk/xmpp/xmppclientsettings.h"
class MessageLoop;
namespace buzz {
-class XmppClient;
+class XmppClientSettings;
} // namespace buzz
namespace net {
@@ -45,19 +45,9 @@ class HostResolver;
} // namespace net
namespace notifier {
-class TaskPump;
-} // namespace notifier
-
-namespace talk_base {
-class SocketServer;
-class Thread;
-} // namespace talk_base
-
-namespace notifier {
-class MediatorThreadImpl
- : public MediatorThread,
- public sigslot::has_slots<> {
+class MediatorThreadImpl : public MediatorThread, public Login::Delegate,
+ public sigslot::has_slots<> {
public:
explicit MediatorThreadImpl(const NotifierOptions& notifier_options);
virtual ~MediatorThreadImpl();
@@ -77,19 +67,20 @@ class MediatorThreadImpl
const std::vector<std::string>& subscribed_services_list);
virtual void SendNotification(const OutgoingNotificationData& data);
+ // Login::Delegate implementation.
+ virtual void OnConnect(base::WeakPtr<talk_base::Task> base_task);
+ virtual void OnDisconnect();
+
protected:
// Should only be called after Start().
MessageLoop* worker_message_loop();
- virtual void OnDisconnect();
-
// These handle messages indicating an event happened in the outside
// world. These are all called from the worker thread. They are protected
// so they can be used by subclasses.
void OnIncomingNotification(
const IncomingNotificationData& notification_data);
void OnOutgoingNotification(bool success);
- void OnConnect(base::WeakPtr<talk_base::Task> parent);
void OnSubscriptionStateChange(bool success);
scoped_refptr<ObserverListThreadSafe<Observer> > observers_;
diff --git a/jingle/notifier/listener/talk_mediator_impl.h b/jingle/notifier/listener/talk_mediator_impl.h
index d5b9d2f..48c284b 100644
--- a/jingle/notifier/listener/talk_mediator_impl.h
+++ b/jingle/notifier/listener/talk_mediator_impl.h
@@ -17,7 +17,6 @@
#include "base/scoped_ptr.h"
#include "jingle/notifier/listener/mediator_thread.h"
#include "jingle/notifier/listener/talk_mediator.h"
-#include "talk/base/sigslot.h"
#include "talk/xmpp/xmppclientsettings.h"
namespace notifier {