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

Side by Side Diff: chrome/browser/sync/notifier/cache_invalidation_packet_handler.h

Issue 9234053: Revert 119171 - Maybe introduced a static initializer - or may be 119173 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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 | « no previous file | chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/threading/non_thread_safe.h" 18 #include "base/threading/non_thread_safe.h"
19 #include "google/cacheinvalidation/v2/system-resources.h" 19 #include "google/cacheinvalidation/v2/system-resources.h"
20 #include "jingle/notifier/listener/push_notifications_listen_task.h"
21 #include "jingle/notifier/listener/push_notifications_subscribe_task.h"
22 20
23 namespace buzz { 21 namespace buzz {
24 class XmppTaskParentInterface; 22 class XmppTaskParentInterface;
25 } // namespace buzz 23 } // namespace buzz
26 24
27 namespace sync_notifier { 25 namespace sync_notifier {
28 26
29 class CacheInvalidationPacketHandler 27 class CacheInvalidationPacketHandler {
30 : public notifier::PushNotificationsSubscribeTaskDelegate,
31 public notifier::PushNotificationsListenTaskDelegate {
32 public: 28 public:
33 // Starts routing packets from |invalidation_client| using 29 // Starts routing packets from |invalidation_client| using
34 // |base_task|. |base_task.get()| must still be non-NULL. 30 // |base_task|. |base_task.get()| must still be non-NULL.
35 // |invalidation_client| must not already be routing packets through 31 // |invalidation_client| must not already be routing packets through
36 // something. Does not take ownership of |invalidation_client|. 32 // something. Does not take ownership of |invalidation_client|.
37 CacheInvalidationPacketHandler( 33 CacheInvalidationPacketHandler(
38 base::WeakPtr<buzz::XmppTaskParentInterface> base_task); 34 base::WeakPtr<buzz::XmppTaskParentInterface> base_task);
39 35
40 // Makes the invalidation client passed into the constructor not 36 // Makes the invalidation client passed into the constructor not
41 // route packets through the XMPP client passed into the constructor 37 // route packets through the XMPP client passed into the constructor
42 // anymore. 38 // anymore.
43 virtual ~CacheInvalidationPacketHandler(); 39 virtual ~CacheInvalidationPacketHandler();
44 40
45 // If |base_task| is non-NULL, sends the outgoing message. 41 // If |base_task| is non-NULL, sends the outgoing message.
46 virtual void SendMessage(const std::string& outgoing_message); 42 virtual void SendMessage(const std::string& outgoing_message);
47 43
48 virtual void SetMessageReceiver( 44 virtual void SetMessageReceiver(
49 invalidation::MessageCallback* incoming_receiver); 45 invalidation::MessageCallback* incoming_receiver);
50 46
51 // Sends a message requesting a subscription to the notification channel.
52 virtual void SendSubscriptionRequest();
53
54 // PushNotificationsSubscribeTaskDelegate implementation.
55 virtual void OnSubscribed() OVERRIDE;
56 virtual void OnSubscriptionError() OVERRIDE;
57
58 // PushNotificationsListenTaskDelegate implementation.
59 virtual void OnNotificationReceived(
60 const notifier::Notification& notification) OVERRIDE;
61
62 private: 47 private:
63 FRIEND_TEST_ALL_PREFIXES(CacheInvalidationPacketHandlerTest, Basic); 48 FRIEND_TEST_ALL_PREFIXES(CacheInvalidationPacketHandlerTest, Basic);
64 49
50 void HandleInboundPacket(const std::string& packet);
51 void HandleChannelContextChange(const std::string& context);
52
65 base::NonThreadSafe non_thread_safe_; 53 base::NonThreadSafe non_thread_safe_;
66 base::WeakPtrFactory<CacheInvalidationPacketHandler> weak_factory_; 54 base::WeakPtrFactory<CacheInvalidationPacketHandler> weak_factory_;
67 55
68 base::WeakPtr<buzz::XmppTaskParentInterface> base_task_; 56 base::WeakPtr<buzz::XmppTaskParentInterface> base_task_;
69 57
70 scoped_ptr<invalidation::MessageCallback> incoming_receiver_; 58 scoped_ptr<invalidation::MessageCallback> incoming_receiver_;
71 59
72 // Parameters for sent messages. 60 // Parameters for sent messages.
73 61
74 // Monotonically increasing sequence number. 62 // Monotonically increasing sequence number.
75 int seq_; 63 int seq_;
76 // Service context. 64 // Unique session token.
77 std::string service_context_; 65 const std::string sid_;
78 // Scheduling hash. 66 // Channel context.
79 int64 scheduling_hash_; 67 std::string channel_context_;
80 68
81 DISALLOW_COPY_AND_ASSIGN(CacheInvalidationPacketHandler); 69 DISALLOW_COPY_AND_ASSIGN(CacheInvalidationPacketHandler);
82 }; 70 };
83 71
84 } // namespace sync_notifier 72 } // namespace sync_notifier
85 73
86 #endif // CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_ 74 #endif // CHROME_BROWSER_SYNC_NOTIFIER_CACHE_INVALIDATION_PACKET_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698