| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Class that handles the details of sending and receiving client | 5 // Class that handles the details of sending and receiving client |
| 6 // invalidation packets. | 6 // invalidation packets. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ | 8 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ |
| 9 #define CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ | 9 #define CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "talk/base/sigslot.h" |
| 15 #include "talk/xmpp/jid.h" | 16 #include "talk/xmpp/jid.h" |
| 17 #include "talk/xmpp/xmppengine.h" |
| 16 | 18 |
| 17 namespace buzz { | 19 namespace buzz { |
| 18 class XmppClient; | 20 class XmppClient; |
| 19 } // namespace buzz | 21 } // namespace buzz |
| 20 | 22 |
| 21 namespace invalidation { | 23 namespace invalidation { |
| 22 class InvalidationClient; | 24 class InvalidationClient; |
| 23 class NetworkEndpoint; | 25 class NetworkEndpoint; |
| 24 } // namespace invalidation | 26 } // namespace invalidation |
| 25 | 27 |
| 26 namespace sync_notifier { | 28 namespace sync_notifier { |
| 27 | 29 |
| 28 // TODO(akalin): Add a NonThreadSafe member to this class and use it. | 30 // TODO(akalin): Add a NonThreadSafe member to this class and use it. |
| 29 | 31 |
| 30 class CacheInvalidationPacketHandler { | 32 class CacheInvalidationPacketHandler : public sigslot::has_slots<> { |
| 31 public: | 33 public: |
| 32 // Starts routing packets from |invalidation_client| through | 34 // Starts routing packets from |invalidation_client| through |
| 33 // |xmpp_client|. |invalidation_client| must not already be routing | 35 // |xmpp_client|. |invalidation_client| must not already be routing |
| 34 // packets through something. Does not take ownership of | 36 // packets through something. Does not take ownership of |
| 35 // |xmpp_client| or |invalidation_client|. | 37 // |xmpp_client| or |invalidation_client|. |
| 36 CacheInvalidationPacketHandler( | 38 CacheInvalidationPacketHandler( |
| 37 buzz::XmppClient* xmpp_client, | 39 buzz::XmppClient* xmpp_client, |
| 38 invalidation::InvalidationClient* invalidation_client); | 40 invalidation::InvalidationClient* invalidation_client); |
| 39 | 41 |
| 40 // Makes the invalidation client passed into the constructor not | 42 // Makes the invalidation client passed into the constructor not |
| 41 // route packets through the XMPP client passed into the constructor | 43 // route packets through the XMPP client passed into the constructor |
| 42 // anymore. | 44 // anymore. |
| 43 ~CacheInvalidationPacketHandler(); | 45 ~CacheInvalidationPacketHandler(); |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 void HandleOutboundPacket( | 48 void HandleOutboundPacket( |
| 47 invalidation::NetworkEndpoint* const& network_endpoint); | 49 invalidation::NetworkEndpoint* const& network_endpoint); |
| 48 | 50 |
| 49 void HandleInboundPacket(const std::string& packet); | 51 void HandleInboundPacket(const std::string& packet); |
| 50 | 52 |
| 53 void OnClientStateChange(buzz::XmppEngine::State state); |
| 54 |
| 51 buzz::XmppClient* xmpp_client_; | 55 buzz::XmppClient* xmpp_client_; |
| 52 invalidation::InvalidationClient* invalidation_client_; | 56 invalidation::InvalidationClient* invalidation_client_; |
| 53 | 57 |
| 54 // Parameters for sent messages. | 58 // Parameters for sent messages. |
| 55 | 59 |
| 56 // Monotonically increasing sequence number. | 60 // Monotonically increasing sequence number. |
| 57 int seq_; | 61 int seq_; |
| 58 // Unique session token. | 62 // Unique session token. |
| 59 const std::string sid_; | 63 const std::string sid_; |
| 60 | 64 |
| 61 DISALLOW_COPY_AND_ASSIGN(CacheInvalidationPacketHandler); | 65 DISALLOW_COPY_AND_ASSIGN(CacheInvalidationPacketHandler); |
| 62 }; | 66 }; |
| 63 | 67 |
| 64 } // namespace sync_notifier | 68 } // namespace sync_notifier |
| 65 | 69 |
| 66 #endif // CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ | 70 #endif // CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ |
| OLD | NEW |