summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 17:21:02 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 17:21:02 +0000
commit7204bfe0667e2dd692196488daa53c1ad8097faa (patch)
tree530e2ca7d8c541079e3f3a0289bed25f318ebe5c
parent69ca222ea3b6a77e470de61fee4ea767641d9ace (diff)
downloadchromium_src-7204bfe0667e2dd692196488daa53c1ad8097faa.zip
chromium_src-7204bfe0667e2dd692196488daa53c1ad8097faa.tar.gz
chromium_src-7204bfe0667e2dd692196488daa53c1ad8097faa.tar.bz2
Made CacheInvalidationPacketHandler aware of XmppClient state changes.
This is a speculative/defensive fix for bug 49274. BUG=49274 TEST=manual (checked that this didn't break normal behavior) Review URL: http://codereview.chromium.org/3054018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53799 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/notifier/DEPS2
-rw-r--r--chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc28
-rw-r--r--chrome/browser/sync/notifier/cache_invalidation_packet_handler.h6
3 files changed, 35 insertions, 1 deletions
diff --git a/chrome/browser/sync/notifier/DEPS b/chrome/browser/sync/notifier/DEPS
index dd31bd4..e9658b7 100644
--- a/chrome/browser/sync/notifier/DEPS
+++ b/chrome/browser/sync/notifier/DEPS
@@ -3,6 +3,8 @@ include_rules = [
"+google/cacheinvalidation",
# sync_notifier depends on the common jingle notifier classes.
"+jingle/notifier",
+ # sync_notifier (temporarily) on the base part of libjingle.
+ "+talk/base",
# sync_notifier depends on the xmpp part of libjingle.
"+talk/xmpp",
]
diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc
index a5d23f2..7edfc73 100644
--- a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc
+++ b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc
@@ -202,6 +202,13 @@ CacheInvalidationPacketHandler::CacheInvalidationPacketHandler(
sid_(MakeSid()) {
CHECK(xmpp_client_);
CHECK(invalidation_client_);
+ if (xmpp_client_->GetState() != buzz::XmppEngine::STATE_OPEN) {
+ LOG(DFATAL) << "non-open xmpp_client_ passed to "
+ << "CacheInvalidationPacketHandler";
+ return;
+ }
+ xmpp_client_->SignalStateChange.connect(
+ this, &CacheInvalidationPacketHandler::OnClientStateChange);
invalidation::NetworkEndpoint* network_endpoint =
invalidation_client_->network_endpoint();
CHECK(network_endpoint);
@@ -227,6 +234,10 @@ CacheInvalidationPacketHandler::~CacheInvalidationPacketHandler() {
void CacheInvalidationPacketHandler::HandleOutboundPacket(
invalidation::NetworkEndpoint* const& network_endpoint) {
CHECK_EQ(network_endpoint, invalidation_client_->network_endpoint());
+ if (!xmpp_client_) {
+ LOG(DFATAL) << "HandleOutboundPacket() called with NULL xmpp_client_";
+ return;
+ }
invalidation::string message;
network_endpoint->TakeOutboundMessage(&message);
std::string encoded_message;
@@ -258,4 +269,21 @@ void CacheInvalidationPacketHandler::HandleInboundPacket(
network_endpoint->HandleInboundMessage(decoded_message);
}
+void CacheInvalidationPacketHandler::OnClientStateChange(
+ buzz::XmppEngine::State state) {
+ switch (state) {
+ case buzz::XmppEngine::STATE_OPEN:
+ LOG(INFO) << "redundant STATE_OPEN message received";
+ break;
+ case buzz::XmppEngine::STATE_CLOSED:
+ LOG(INFO) << "xmpp_client_ closed -- setting to NULL";
+ xmpp_client_->SignalStateChange.disconnect(this);
+ xmpp_client_ = NULL;
+ break;
+ default:
+ LOG(INFO) << "xmpp_client_ state changed to " << state;
+ break;
+ }
+}
+
} // namespace sync_notifier
diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h
index e3e89f2..b1ed258 100644
--- a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h
+++ b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h
@@ -12,7 +12,9 @@
#include <string>
#include "base/basictypes.h"
+#include "talk/base/sigslot.h"
#include "talk/xmpp/jid.h"
+#include "talk/xmpp/xmppengine.h"
namespace buzz {
class XmppClient;
@@ -27,7 +29,7 @@ namespace sync_notifier {
// TODO(akalin): Add a NonThreadSafe member to this class and use it.
-class CacheInvalidationPacketHandler {
+class CacheInvalidationPacketHandler : public sigslot::has_slots<> {
public:
// Starts routing packets from |invalidation_client| through
// |xmpp_client|. |invalidation_client| must not already be routing
@@ -48,6 +50,8 @@ class CacheInvalidationPacketHandler {
void HandleInboundPacket(const std::string& packet);
+ void OnClientStateChange(buzz::XmppEngine::State state);
+
buzz::XmppClient* xmpp_client_;
invalidation::InvalidationClient* invalidation_client_;