summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 07:59:58 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 07:59:58 +0000
commit9e2fa21e45b5d7e635a8b3d57fcc4ca31883e1db (patch)
tree4f9fe8a49be3267f693c2e638355c9edb2e3def7 /chrome/browser/sync
parentf7fa0c0b519b468c9d094222faf2e470703c66fa (diff)
downloadchromium_src-9e2fa21e45b5d7e635a8b3d57fcc4ca31883e1db.zip
chromium_src-9e2fa21e45b5d7e635a8b3d57fcc4ca31883e1db.tar.gz
chromium_src-9e2fa21e45b5d7e635a8b3d57fcc4ca31883e1db.tar.bz2
Fixed notifications-related bug on network reconnections.
Tied talk_mediator logged_in state to mediator_thread instead of auth_watcher. Added some extra logging. BUG=34117 TEST=see bug Review URL: http://codereview.chromium.org/566028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rwxr-xr-xchrome/browser/sync/engine/syncapi.cc3
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_impl.cc13
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_impl.h6
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc1
4 files changed, 16 insertions, 7 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 7e898ce..21b6f48f 100755
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -1583,6 +1583,9 @@ void SyncManager::SyncInternal::HandleSyncerEvent(const SyncerEvent& event) {
bool success = talk_mediator()->SendNotification();
if (success) {
notification_pending_ = false;
+ LOG(INFO) << "Sent XMPP notification";
+ } else {
+ LOG(INFO) << "Could not send XMPP notification";
}
} else {
LOG(INFO) << "Didn't send XMPP notification!"
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc b/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
index 2433c08..a147e66 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
@@ -93,9 +93,7 @@ void TalkMediatorImpl::AuthWatcherEventHandler(
// insure this code path is stable.
break;
case AuthWatcherEvent::AUTH_SUCCEEDED:
- if (!state_.logged_in) {
- DoLogin();
- }
+ DoLogin();
break;
default:
// Do nothing.
@@ -116,6 +114,7 @@ bool TalkMediatorImpl::Login() {
}
bool TalkMediatorImpl::DoLogin() {
+ mutex_.AssertAcquired();
// Connect to the mediator thread and start processing messages.
if (!state_.connected) {
mediator_thread_->SignalStateChange.connect(
@@ -123,9 +122,9 @@ bool TalkMediatorImpl::DoLogin() {
&TalkMediatorImpl::MediatorThreadMessageHandler);
state_.connected = 1;
}
- if (state_.initialized && !state_.logged_in) {
+ if (state_.initialized && !state_.logging_in) {
mediator_thread_->Login(xmpp_settings_);
- state_.logged_in = 1;
+ state_.logging_in = 1;
return true;
}
return false;
@@ -141,6 +140,7 @@ bool TalkMediatorImpl::Logout() {
if (state_.started) {
mediator_thread_->Logout();
state_.started = 0;
+ state_.logging_in = 0;
state_.logged_in = 0;
state_.subscribed = 0;
return true;
@@ -213,6 +213,8 @@ void TalkMediatorImpl::MediatorThreadMessageHandler(
void TalkMediatorImpl::OnLogin() {
LOG(INFO) << "P2P: Logged in.";
AutoLock lock(mutex_);
+ state_.logging_in = 0;
+ state_.logged_in = 1;
// ListenForUpdates enables the ListenTask. This is done before
// SubscribeForUpdates.
mediator_thread_->ListenForUpdates();
@@ -225,6 +227,7 @@ void TalkMediatorImpl::OnLogout() {
LOG(INFO) << "P2P: Logged off.";
OnSubscriptionFailure();
AutoLock lock(mutex_);
+ state_.logging_in = 0;
state_.logged_in = 0;
TalkMediatorEvent event = { TalkMediatorEvent::LOGOUT_SUCCEEDED };
channel_->NotifyListeners(event);
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_impl.h b/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
index 99bbb79..922624e 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
@@ -49,13 +49,15 @@ class TalkMediatorImpl
private:
struct TalkMediatorState {
TalkMediatorState()
- : started(0), connected(0), initialized(0), logged_in(0),
- subscribed(0) {
+ : started(0), connected(0), initialized(0), logging_in(0),
+ logged_in(0), subscribed(0) {
}
unsigned int started : 1; // Background thread has started.
unsigned int connected : 1; // Connected to the mediator thread signal.
unsigned int initialized : 1; // Initialized with login information.
+ unsigned int logging_in : 1; // Logging in to the mediator's
+ // authenticator.
unsigned int logged_in : 1; // Logged in the mediator's authenticator.
unsigned int subscribed : 1; // Subscribed to the xmpp receiving channel.
};
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc b/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
index fb5e9a9..280a8a9 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
@@ -111,6 +111,7 @@ TEST_F(TalkMediatorImplTest, SendNotification) {
ASSERT_TRUE(talk1->SetAuthToken("chromium@gmail.com", "token") == true);
ASSERT_TRUE(talk1->Login() == true);
+ talk1->OnLogin();
ASSERT_TRUE(mock->login_calls == 1);
// Failure due to not being subscribed.