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 #ifndef CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_ | 5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ |
6 #define CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_ | 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ |
7 | 7 |
8 #include "sync/notifier/invalidation_util.h" | 8 #include "sync/notifier/invalidation_util.h" |
| 9 #include "sync/notifier/invalidator_state.h" |
9 | 10 |
10 namespace syncer { | 11 namespace syncer { |
11 class InvalidationHandler; | 12 class InvalidationHandler; |
| 13 class AckHandle; |
12 } // namespace syncer | 14 } // namespace syncer |
13 | 15 |
| 16 namespace invalidation { |
| 17 |
14 // Interface for classes that handle invalidation registrations and send out | 18 // Interface for classes that handle invalidation registrations and send out |
15 // invalidations to register handlers. | 19 // invalidations to register handlers. |
16 // | 20 // |
17 // Invalidation clients should follow the pattern below: | 21 // Invalidation clients should follow the pattern below: |
18 // | 22 // |
19 // When starting the client: | 23 // When starting the client: |
20 // | 24 // |
21 // frontend->RegisterInvalidationHandler(client_handler); | 25 // frontend->RegisterInvalidationHandler(client_handler); |
22 // | 26 // |
23 // When the set of IDs to register changes for the client during its lifetime | 27 // When the set of IDs to register changes for the client during its lifetime |
24 // (i.e., between calls to RegisterInvalidationHandler(client_handler) and | 28 // (i.e., between calls to RegisterInvalidationHandler(client_handler) and |
25 // UnregisterInvalidationHandler(client_handler): | 29 // UnregisterInvalidationHandler(client_handler): |
26 // | 30 // |
27 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids); | 31 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids); |
28 // | 32 // |
29 // When shutting down the client for browser shutdown: | 33 // To unregister for all invalidations: |
30 // | 34 // |
31 // frontend->UnregisterInvalidationHandler(client_handler); | 35 // frontend->UnregisterInvalidationHandler(client_handler); |
32 // | 36 // |
33 // Note that there's no call to UpdateRegisteredIds() -- this is because the | |
34 // invalidation API persists registrations across browser restarts. | |
35 // | |
36 // When permanently shutting down the client, e.g. when disabling the related | |
37 // feature: | |
38 // | |
39 // frontend->UpdateRegisteredInvalidationIds(client_handler, ObjectIdSet()); | |
40 // frontend->UnregisterInvalidationHandler(client_handler); | |
41 // | |
42 // If an invalidation handler cares about the invalidator state, it should also | 37 // If an invalidation handler cares about the invalidator state, it should also |
43 // do the following when starting the client: | 38 // do the following when starting the client: |
44 // | 39 // |
45 // invalidator_state = frontend->GetInvalidatorState(); | 40 // invalidator_state = frontend->GetInvalidatorState(); |
46 // | 41 // |
47 // It can also do the above in OnInvalidatorStateChange(), or it can use the | 42 // It can also do the above in OnInvalidatorStateChange(), or it can use the |
48 // argument to OnInvalidatorStateChange(). | 43 // argument to OnInvalidatorStateChange(). |
49 // | 44 // |
50 // It is an error to have registered handlers when an | 45 // It is an error to have registered handlers when an InvalidationFrontend is |
51 // InvalidationFrontend is shut down; clients must ensure that they | 46 // shut down; clients must ensure that they unregister themselves before then. |
52 // unregister themselves before then. (Depending on the | 47 // |
53 // InvalidationFrontend, shutdown may be equivalent to destruction, or | 48 // TODO(rlarocque): This class should extend ProfileKeyedService. |
54 // a separate function call like Shutdown()). | |
55 // | 49 // |
56 // NOTE(akalin): Invalidations that come in during browser shutdown may get | 50 // NOTE(akalin): Invalidations that come in during browser shutdown may get |
57 // dropped. This won't matter once we have an Acknowledge API, though: see | 51 // dropped. This won't matter once we have an Acknowledge API, though: see |
58 // http://crbug.com/78462 and http://crbug.com/124149. | 52 // http://crbug.com/78462 and http://crbug.com/124149. |
59 class InvalidationFrontend { | 53 class InvalidationFrontend { |
60 public: | 54 public: |
61 // Starts sending notifications to |handler|. |handler| must not be NULL, | 55 // Starts sending notifications to |handler|. |handler| must not be NULL, |
62 // and it must not already be registered. | 56 // and it must not already be registered. |
63 // | 57 // |
64 // Handler registrations are persisted across restarts of sync. | 58 // Handler registrations are persisted across restarts of sync. |
(...skipping 24 matching lines...) Expand all Loading... |
89 | 83 |
90 // Returns the current invalidator state. When called from within | 84 // Returns the current invalidator state. When called from within |
91 // InvalidationHandler::OnInvalidatorStateChange(), this must return | 85 // InvalidationHandler::OnInvalidatorStateChange(), this must return |
92 // the updated state. | 86 // the updated state. |
93 virtual syncer::InvalidatorState GetInvalidatorState() const = 0; | 87 virtual syncer::InvalidatorState GetInvalidatorState() const = 0; |
94 | 88 |
95 protected: | 89 protected: |
96 virtual ~InvalidationFrontend() { } | 90 virtual ~InvalidationFrontend() { } |
97 }; | 91 }; |
98 | 92 |
99 #endif // CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_ | 93 } // namespace invalidation |
| 94 |
| 95 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ |
OLD | NEW |