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

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

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