Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2774)

Unified Diff: chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc

Issue 3054018: Made CacheInvalidationPacketHandler aware of XmppClient state changes. (Closed)
Patch Set: fixed deps Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/notifier/cache_invalidation_packet_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc
diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc
index a5d23f2d68d0aa98f0fb0c3b878fa508dfa4f070..7edfc736d50fd1703d082aebdeb32b080c11330a 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
« no previous file with comments | « chrome/browser/sync/notifier/cache_invalidation_packet_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698