OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Interface to the sync notifier, which is an object that receives | 5 // Interface to the sync notifier, which is an object that receives |
6 // notifications when updates are available for a set of sync types. | 6 // notifications when updates are available for a set of sync types. |
7 // All the observers are notified when such an event happens. | 7 // All the observers are notified when such an event happens. |
8 | 8 |
9 #ifndef SYNC_NOTIFIER_SYNC_NOTIFIER_H_ | 9 #ifndef SYNC_NOTIFIER_SYNC_NOTIFIER_H_ |
10 #define SYNC_NOTIFIER_SYNC_NOTIFIER_H_ | 10 #define SYNC_NOTIFIER_SYNC_NOTIFIER_H_ |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
15 #include "sync/notifier/invalidation_util.h" | 15 #include "sync/notifier/invalidation_util.h" |
16 | 16 |
17 namespace syncer { | 17 namespace syncer { |
18 class SyncNotifierObserver; | 18 class SyncNotifierObserver; |
19 | 19 |
20 class SyncNotifier { | 20 class SyncNotifier { |
21 public: | 21 public: |
22 SyncNotifier() {} | 22 SyncNotifier() {} |
23 virtual ~SyncNotifier() {} | 23 virtual ~SyncNotifier() {} |
24 | 24 |
25 // Updates the set of ObjectIds associated with a given | 25 // Sets the handler for the given name. Pass in NULL for |handler| |
msw
2012/08/03 23:30:46
nit: line breaks :)
akalin
2012/08/07 07:25:19
Done.
| |
26 // |handler|. Passing an empty ObjectIdSet will unregister | 26 // if you want to remove the handler for the given name. (This |
27 // |handler|. There should be at most one handler registered per | 27 // doesn't unregister the IDs for the given name, though.) A |
28 // object id. | 28 // handler must be set for at most one name. |
29 virtual void UpdateRegisteredIds(SyncNotifierObserver* handler, | 29 virtual void SetHandler(const std::string& handler_name, |
30 SyncNotifierObserver* handler) = 0; | |
31 | |
32 // Updates the set of ObjectIds associated with a given handler (via | |
33 // its name). An ID must be registered for at most one handler. | |
34 virtual void UpdateRegisteredIds(const std::string& handler_name, | |
30 const ObjectIdSet& ids) = 0; | 35 const ObjectIdSet& ids) = 0; |
31 | 36 |
32 // SetUniqueId must be called once, before any call to | 37 // SetUniqueId must be called once, before any call to |
33 // UpdateCredentials. |unique_id| should be a non-empty globally | 38 // UpdateCredentials. |unique_id| should be a non-empty globally |
34 // unique string. | 39 // unique string. |
35 virtual void SetUniqueId(const std::string& unique_id) = 0; | 40 virtual void SetUniqueId(const std::string& unique_id) = 0; |
36 | 41 |
37 // SetState must be called once, before any call to | 42 // SetState must be called once, before any call to |
38 // UpdateCredentials. |state| may be empty. | 43 // UpdateCredentials. |state| may be empty. |
39 // Deprecated in favour of InvalidationStateTracker persistence. | 44 // Deprecated in favour of InvalidationStateTracker persistence. |
40 virtual void SetStateDeprecated(const std::string& state) = 0; | 45 virtual void SetStateDeprecated(const std::string& state) = 0; |
41 | 46 |
42 // The observers won't be notified of any notifications until | 47 // The observers won't be notified of any notifications until |
43 // UpdateCredentials is called at least once. It can be called more than | 48 // UpdateCredentials is called at least once. It can be called more than |
44 // once. | 49 // once. |
45 virtual void UpdateCredentials( | 50 virtual void UpdateCredentials( |
46 const std::string& email, const std::string& token) = 0; | 51 const std::string& email, const std::string& token) = 0; |
47 | 52 |
48 // This is here only to support the old p2p notification implementation, | 53 // This is here only to support the old p2p notification implementation, |
49 // which is still used by sync integration tests. | 54 // which is still used by sync integration tests. |
50 // TODO(akalin): Remove this once we move the integration tests off p2p | 55 // TODO(akalin): Remove this once we move the integration tests off p2p |
51 // notifications. | 56 // notifications. |
52 virtual void SendNotification(ModelTypeSet changed_types) = 0; | 57 virtual void SendNotification(ModelTypeSet changed_types) = 0; |
53 }; | 58 }; |
54 } // namespace syncer | 59 } // namespace syncer |
55 | 60 |
56 #endif // SYNC_NOTIFIER_SYNC_NOTIFIER_H_ | 61 #endif // SYNC_NOTIFIER_SYNC_NOTIFIER_H_ |
OLD | NEW |