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

Side by Side Diff: trunk/src/sync/tools/testserver/xmppserver.py

Issue 17610004: Revert 208315 "Make use of InvalidationService" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/sync/tools/sync_listen_notifications.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A bare-bones and non-compliant XMPP server. 5 """A bare-bones and non-compliant XMPP server.
6 6
7 Just enough of the protocol is implemented to get it to work with 7 Just enough of the protocol is implemented to get it to work with
8 Chrome's sync notification system. 8 Chrome's sync notification system.
9 """ 9 """
10 10
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 channel: The channel on which to send the notification. 568 channel: The channel on which to send the notification.
569 data: The notification payload. 569 data: The notification payload.
570 """ 570 """
571 notification_stanza = self.MakeNotification(channel, data) 571 notification_stanza = self.MakeNotification(channel, data)
572 self.ForwardNotification(None, notification_stanza) 572 self.ForwardNotification(None, notification_stanza)
573 notification_stanza.unlink() 573 notification_stanza.unlink()
574 574
575 def SetAuthenticated(self, auth_valid): 575 def SetAuthenticated(self, auth_valid):
576 self._authenticated = auth_valid 576 self._authenticated = auth_valid
577 577
578 # We check authentication only when establishing new connections. We close
579 # all existing connections here to make sure previously connected clients
580 # pick up on the change. It's a hack, but it works well enough for our
581 # purposes.
582 if not self._authenticated:
583 for connection in self._handshake_done_connections:
584 connection.close()
585
586 def GetAuthenticated(self): 578 def GetAuthenticated(self):
587 return self._authenticated 579 return self._authenticated
588 580
589 # XmppConnection delegate methods. 581 # XmppConnection delegate methods.
590 def OnXmppHandshakeDone(self, xmpp_connection): 582 def OnXmppHandshakeDone(self, xmpp_connection):
591 self._handshake_done_connections.add(xmpp_connection) 583 self._handshake_done_connections.add(xmpp_connection)
592 584
593 def OnXmppConnectionClosed(self, xmpp_connection): 585 def OnXmppConnectionClosed(self, xmpp_connection):
594 self._connections.discard(xmpp_connection) 586 self._connections.discard(xmpp_connection)
595 self._handshake_done_connections.discard(xmpp_connection) 587 self._handshake_done_connections.discard(xmpp_connection)
596 588
597 def ForwardNotification(self, unused_xmpp_connection, notification_stanza): 589 def ForwardNotification(self, unused_xmpp_connection, notification_stanza):
598 if self._notifications_enabled: 590 if self._notifications_enabled:
599 for connection in self._handshake_done_connections: 591 for connection in self._handshake_done_connections:
600 print 'Sending notification to %s' % connection 592 print 'Sending notification to %s' % connection
601 connection.ForwardNotification(notification_stanza) 593 connection.ForwardNotification(notification_stanza)
602 else: 594 else:
603 print 'Notifications disabled; dropping notification' 595 print 'Notifications disabled; dropping notification'
OLDNEW
« no previous file with comments | « trunk/src/sync/tools/sync_listen_notifications.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698