OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ | |
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ | |
7 | |
8 #include "sync/notifier/invalidation_util.h" | |
9 #include "sync/notifier/invalidator_state.h" | |
10 | |
11 namespace syncer { | |
12 class InvalidationHandler; | |
13 class AckHandle; | |
14 } // namespace syncer | |
15 | |
16 namespace invalidation { | |
17 | |
18 // Interface for classes that handle invalidation registrations and send out | |
19 // invalidations to register handlers. | |
20 // | |
21 // Invalidation clients should follow the pattern below: | |
22 // | |
23 // When starting the client: | |
24 // | |
25 // frontend->RegisterInvalidationHandler(client_handler); | |
26 // | |
27 // When the set of IDs to register changes for the client during its lifetime | |
28 // (i.e., between calls to RegisterInvalidationHandler(client_handler) and | |
29 // UnregisterInvalidationHandler(client_handler): | |
30 // | |
31 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids); | |
32 // | |
33 // To unregister for all invalidations: | |
34 // | |
35 // frontend->UnregisterInvalidationHandler(client_handler); | |
36 // | |
37 // If an invalidation handler cares about the invalidator state, it should also | |
38 // do the following when starting the client: | |
39 // | |
40 // invalidator_state = frontend->GetInvalidatorState(); | |
41 // | |
42 // It can also do the above in OnInvalidatorStateChange(), or it can use the | |
43 // argument to OnInvalidatorStateChange(). | |
44 // | |
45 // It is an error to have registered handlers when an InvalidationFrontend is | |
46 // shut down; clients must ensure that they unregister themselves before then. | |
47 // | |
48 // TODO(rlarocque): This class should extend BrowserContextKeyedService. | |
49 // | |
50 // NOTE(akalin): Invalidations that come in during browser shutdown may get | |
51 // dropped. This won't matter once we have an Acknowledge API, though: see | |
52 // http://crbug.com/78462 and http://crbug.com/124149. | |
53 class InvalidationFrontend { | |
54 public: | |
55 // Starts sending notifications to |handler|. |handler| must not be NULL, | |
56 // and it must not already be registered. | |
57 // | |
58 // Handler registrations are persisted across restarts of sync. | |
59 virtual void RegisterInvalidationHandler( | |
60 syncer::InvalidationHandler* handler) = 0; | |
61 | |
62 // Updates the set of ObjectIds associated with |handler|. |handler| must | |
63 // not be NULL, and must already be registered. An ID must be registered for | |
64 // at most one handler. | |
65 // | |
66 // Registered IDs are persisted across restarts of sync. | |
67 virtual void UpdateRegisteredInvalidationIds( | |
68 syncer::InvalidationHandler* handler, | |
69 const syncer::ObjectIdSet& ids) = 0; | |
70 | |
71 // Stops sending notifications to |handler|. |handler| must not be NULL, and | |
72 // it must already be registered. Note that this doesn't unregister the IDs | |
73 // associated with |handler|. | |
74 // | |
75 // Handler registrations are persisted across restarts of sync. | |
76 virtual void UnregisterInvalidationHandler( | |
77 syncer::InvalidationHandler* handler) = 0; | |
78 | |
79 // Sends an acknowledgement that an invalidation for |id| was successfully | |
80 // handled. | |
81 virtual void AcknowledgeInvalidation(const invalidation::ObjectId& id, | |
82 const syncer::AckHandle& ack_handle) = 0; | |
83 | |
84 // Returns the current invalidator state. When called from within | |
85 // InvalidationHandler::OnInvalidatorStateChange(), this must return | |
86 // the updated state. | |
87 virtual syncer::InvalidatorState GetInvalidatorState() const = 0; | |
88 | |
89 protected: | |
90 virtual ~InvalidationFrontend() { } | |
91 }; | |
92 | |
93 } // namespace invalidation | |
94 | |
95 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ | |
OLD | NEW |