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_INVALIDATION_INVALIDATION_FRONTEND_H_ | 5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_ |
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ | 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_ |
7 | 7 |
| 8 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
8 #include "sync/notifier/invalidation_util.h" | 9 #include "sync/notifier/invalidation_util.h" |
9 #include "sync/notifier/invalidator_state.h" | 10 #include "sync/notifier/invalidator_state.h" |
10 | 11 |
11 namespace syncer { | 12 namespace syncer { |
12 class InvalidationHandler; | 13 class InvalidationHandler; |
13 class AckHandle; | 14 class AckHandle; |
14 } // namespace syncer | 15 } // namespace syncer |
15 | 16 |
16 namespace invalidation { | 17 namespace invalidation { |
17 | 18 |
(...skipping 17 matching lines...) Expand all Loading... |
35 // frontend->UnregisterInvalidationHandler(client_handler); | 36 // frontend->UnregisterInvalidationHandler(client_handler); |
36 // | 37 // |
37 // If an invalidation handler cares about the invalidator state, it should also | 38 // If an invalidation handler cares about the invalidator state, it should also |
38 // do the following when starting the client: | 39 // do the following when starting the client: |
39 // | 40 // |
40 // invalidator_state = frontend->GetInvalidatorState(); | 41 // invalidator_state = frontend->GetInvalidatorState(); |
41 // | 42 // |
42 // It can also do the above in OnInvalidatorStateChange(), or it can use the | 43 // It can also do the above in OnInvalidatorStateChange(), or it can use the |
43 // argument to OnInvalidatorStateChange(). | 44 // argument to OnInvalidatorStateChange(). |
44 // | 45 // |
45 // It is an error to have registered handlers when an InvalidationFrontend is | 46 // It is an error to have registered handlers when an InvalidationService is |
46 // shut down; clients must ensure that they unregister themselves before then. | 47 // shut down; clients must ensure that they unregister themselves before then. |
47 // | 48 // |
48 // TODO(rlarocque): This class should extend ProfileKeyedService. | |
49 // | |
50 // NOTE(akalin): Invalidations that come in during browser shutdown may get | 49 // 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 | 50 // dropped. This won't matter once we have an Acknowledge API, though: see |
52 // http://crbug.com/78462 and http://crbug.com/124149. | 51 // http://crbug.com/78462 and http://crbug.com/124149. |
53 class InvalidationFrontend { | 52 // |
| 53 // This class inherits from ProfileKeyedService to make it possible to correctly |
| 54 // cast from various InvalidationService implementations to ProfileKeyedService |
| 55 // in InvalidationServiceFactory. |
| 56 class InvalidationService : public ProfileKeyedService { |
54 public: | 57 public: |
55 // Starts sending notifications to |handler|. |handler| must not be NULL, | 58 // Starts sending notifications to |handler|. |handler| must not be NULL, |
56 // and it must not already be registered. | 59 // and it must not already be registered. |
57 // | 60 // |
58 // Handler registrations are persisted across restarts of sync. | 61 // Handler registrations are persisted across restarts of sync. |
59 virtual void RegisterInvalidationHandler( | 62 virtual void RegisterInvalidationHandler( |
60 syncer::InvalidationHandler* handler) = 0; | 63 syncer::InvalidationHandler* handler) = 0; |
61 | 64 |
62 // Updates the set of ObjectIds associated with |handler|. |handler| must | 65 // 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 | 66 // not be NULL, and must already be registered. An ID must be registered for |
(...skipping 15 matching lines...) Expand all Loading... |
79 // Sends an acknowledgement that an invalidation for |id| was successfully | 82 // Sends an acknowledgement that an invalidation for |id| was successfully |
80 // handled. | 83 // handled. |
81 virtual void AcknowledgeInvalidation(const invalidation::ObjectId& id, | 84 virtual void AcknowledgeInvalidation(const invalidation::ObjectId& id, |
82 const syncer::AckHandle& ack_handle) = 0; | 85 const syncer::AckHandle& ack_handle) = 0; |
83 | 86 |
84 // Returns the current invalidator state. When called from within | 87 // Returns the current invalidator state. When called from within |
85 // InvalidationHandler::OnInvalidatorStateChange(), this must return | 88 // InvalidationHandler::OnInvalidatorStateChange(), this must return |
86 // the updated state. | 89 // the updated state. |
87 virtual syncer::InvalidatorState GetInvalidatorState() const = 0; | 90 virtual syncer::InvalidatorState GetInvalidatorState() const = 0; |
88 | 91 |
| 92 // Returns the ID belonging to this invalidation client. Can be used to |
| 93 // prevent the receipt of notifications of our own changes. |
| 94 virtual std::string GetInvalidatorClientId() const = 0; |
| 95 |
89 protected: | 96 protected: |
90 virtual ~InvalidationFrontend() { } | 97 virtual ~InvalidationService() { } |
91 }; | 98 }; |
92 | 99 |
93 } // namespace invalidation | 100 } // namespace invalidation |
94 | 101 |
95 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ | 102 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_ |
OLD | NEW |