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 // 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. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 virtual void SubscribeForUpdates( | 52 virtual void SubscribeForUpdates( |
53 const std::vector<std::string>& subscribed_services_list); | 53 const std::vector<std::string>& subscribed_services_list); |
54 | 54 |
55 // Overridden to stop listening to server notifications. | 55 // Overridden to stop listening to server notifications. |
56 virtual void Logout(); | 56 virtual void Logout(); |
57 | 57 |
58 // Must not be called. | 58 // Must not be called. |
59 virtual void SendNotification(const OutgoingNotificationData& data); | 59 virtual void SendNotification(const OutgoingNotificationData& data); |
60 | 60 |
61 // ChromeInvalidationClient::Listener implementation. | 61 // ChromeInvalidationClient::Listener implementation. |
62 virtual void OnInvalidate(syncable::ModelType model_type); | 62 // We pass on two pieces of information to observers through the |
| 63 // IncomingNotificationData. |
| 64 // - the model type being invalidated, through IncomingNotificationData's |
| 65 // service_url. |
| 66 // - the invalidation payload for that model type, through |
| 67 // IncomingNotificationData's service_specific_data. |
| 68 virtual void OnInvalidate(syncable::ModelType model_type, |
| 69 const std::string& payload); |
63 virtual void OnInvalidateAll(); | 70 virtual void OnInvalidateAll(); |
64 | 71 |
65 // StateWriter implementation. | 72 // StateWriter implementation. |
66 virtual void WriteState(const std::string& state); | 73 virtual void WriteState(const std::string& state); |
67 | 74 |
68 private: | 75 private: |
69 // Posted to the worker thread by ListenForUpdates(). | 76 // Posted to the worker thread by ListenForUpdates(). |
70 void DoListenForUpdates(); | 77 void DoListenForUpdates(); |
71 | 78 |
72 // Posted to the worker thread by SubscribeForUpdates(). | 79 // Posted to the worker thread by SubscribeForUpdates(). |
73 void RegisterTypesAndSignalSubscribed(); | 80 void RegisterTypesAndSignalSubscribed(); |
74 | 81 |
75 // Posted to the worker thread by Logout(). | 82 // Posted to the worker thread by Logout(). |
76 void StopInvalidationListener(); | 83 void StopInvalidationListener(); |
77 | 84 |
78 std::string state_; | 85 std::string state_; |
79 // Hack to get the nice thread-safe behavior for |state_writer_|. | 86 // Hack to get the nice thread-safe behavior for |state_writer_|. |
80 scoped_refptr<ObserverListThreadSafe<StateWriter> > state_writers_; | 87 scoped_refptr<ObserverListThreadSafe<StateWriter> > state_writers_; |
81 // We still need to keep |state_writer_| around to remove it from | 88 // We still need to keep |state_writer_| around to remove it from |
82 // |state_writers_|. | 89 // |state_writers_|. |
83 StateWriter* state_writer_; | 90 StateWriter* state_writer_; |
84 scoped_ptr<ChromeInvalidationClient> chrome_invalidation_client_; | 91 scoped_ptr<ChromeInvalidationClient> chrome_invalidation_client_; |
85 }; | 92 }; |
86 | 93 |
87 } // namespace sync_notifier | 94 } // namespace sync_notifier |
88 | 95 |
89 DISABLE_RUNNABLE_METHOD_REFCOUNT(sync_notifier::ServerNotifierThread); | 96 DISABLE_RUNNABLE_METHOD_REFCOUNT(sync_notifier::ServerNotifierThread); |
90 | 97 |
91 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SERVER_NOTIFIER_THREAD_H_ | 98 #endif // CHROME_BROWSER_SYNC_NOTIFIER_SERVER_NOTIFIER_THREAD_H_ |
OLD | NEW |