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

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

Issue 2827014: Implemented initial version of server-issued notification client. (Closed)
Patch Set: Added DEPS Created 10 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // This class is the (hackish) way to use the XMPP parts of
6 // MediatorThread for server-issued notifications.
7 //
8 // TODO(akalin): Decomp MediatorThread into an XMPP service part and a
9 // notifications-specific part and use the XMPP service part for
10 // server-issued notifications.
11
12 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_SERVER_NOTIFIER_THREAD_H_
13 #define CHROME_BROWSER_SYNC_NOTIFIER_SERVER_NOTIFIER_THREAD_H_
14
15 #include <string>
16 #include <vector>
17
18 #include "base/scoped_ptr.h"
19 #include "base/task.h"
20 #include "chrome/common/net/notifier/listener/mediator_thread_impl.h"
21 #include "google/cacheinvalidation/invalidation-client.h"
22
23 namespace chrome_common_net {
24 class NetworkChangeNotifierThread;
25 } // namespace chrome_common_net
26
27 namespace sync_notifier {
28
29 class ChromeInvalidationClient;
30
31 class ServerNotifierThread
32 : public notifier::MediatorThreadImpl,
33 public invalidation::InvalidationListener {
34 public:
35 explicit ServerNotifierThread(
36 chrome_common_net::NetworkChangeNotifierThread*
37 network_change_notifier_thread);
38
39 virtual ~ServerNotifierThread();
40
41 // Overridden to start listening to server notifications.
42 virtual void ListenForUpdates();
43
44 // Overridden to immediately notify the delegate that subscriptions
45 // (i.e., notifications) are on. Must be called only after a call
46 // to ListenForUpdates().
47 virtual void SubscribeForUpdates(
48 const std::vector<std::string>& subscribed_services_list);
49
50 // Overridden to also stop listening to server notifications.
51 virtual void Logout();
52
53 // Must not be called.
54 virtual void SendNotification(const OutgoingNotificationData& data);
55
56 // invalidation::InvalidationListener implementation.
57
58 virtual void Invalidate(const invalidation::Invalidation& invalidation,
59 invalidation::Closure* callback);
60
61 virtual void InvalidateAll(invalidation::Closure* callback);
62
63 virtual void AllRegistrationsLost(invalidation::Closure* callback);
64
65 virtual void RegistrationLost(const invalidation::ObjectId& object_id,
66 invalidation::Closure* callback);
67
68 private:
69 // Posted to the worker thread by ListenForUpdates().
70 void StartInvalidationListener();
71
72 // Posted to the worker thread by SubscribeForUpdates().
73 void RegisterTypesAndSignalSubscribed();
74
75 // Register the sync types that we're interested in getting
76 // notifications for.
77 void RegisterTypes();
78
79 // Called when we get a registration response back.
80 void RegisterCallback(
81 const invalidation::RegistrationUpdateResult& result);
82
83 // Signal to the delegate that we're subscribed.
84 void SignalSubscribed();
85
86 // Signal to the delegate that we have an incoming notification.
87 void SignalIncomingNotification();
88
89 // Called by StartInvalidationListener() and posted to the worker
90 // thread by Stop().
91 void StopInvalidationListener();
92
93 scoped_ptr<ChromeInvalidationClient> chrome_invalidation_client_;
94 };
95
96 } // namespace sync_notifier
97
98 DISABLE_RUNNABLE_METHOD_REFCOUNT(sync_notifier::ServerNotifierThread);
99
100 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SERVER_NOTIFIER_THREAD_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/invalidation_util.cc ('k') | chrome/browser/sync/notifier/server_notifier_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698