Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/browser/invalidation/invalidation_service.h

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
18 // Interface for classes that handle invalidation registrations and send out 19 // Interface for classes that handle invalidation registrations and send out
19 // invalidations to register handlers. 20 // invalidations to register handlers.
20 // 21 //
21 // Invalidation clients should follow the pattern below: 22 // Invalidation clients should follow the pattern below:
22 // 23 //
23 // When starting the client: 24 // When starting the client:
24 // 25 //
25 // frontend->RegisterInvalidationHandler(client_handler); 26 // frontend->RegisterInvalidationHandler(client_handler);
26 // 27 //
27 // When the set of IDs to register changes for the client during its lifetime 28 // 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 // (i.e., between calls to RegisterInvalidationHandler(client_handler) and
29 // UnregisterInvalidationHandler(client_handler): 30 // UnregisterInvalidationHandler(client_handler):
30 // 31 //
31 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids); 32 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids);
32 // 33 //
33 // To unregister for all invalidations: 34 // When shutting down the client for browser shutdown:
34 // 35 //
35 // frontend->UnregisterInvalidationHandler(client_handler); 36 // frontend->UnregisterInvalidationHandler(client_handler);
36 // 37 //
38 // Note that there's no call to UpdateRegisteredIds() -- this is because the
39 // invalidation API persists registrations across browser restarts.
40 //
41 // When permanently shutting down the client, e.g. when disabling the related
42 // feature:
43 //
44 // frontend->UpdateRegisteredInvalidationIds(client_handler, ObjectIdSet());
45 // frontend->UnregisterInvalidationHandler(client_handler);
46 //
37 // If an invalidation handler cares about the invalidator state, it should also 47 // If an invalidation handler cares about the invalidator state, it should also
38 // do the following when starting the client: 48 // do the following when starting the client:
39 // 49 //
40 // invalidator_state = frontend->GetInvalidatorState(); 50 // invalidator_state = frontend->GetInvalidatorState();
41 // 51 //
42 // It can also do the above in OnInvalidatorStateChange(), or it can use the 52 // It can also do the above in OnInvalidatorStateChange(), or it can use the
43 // argument to OnInvalidatorStateChange(). 53 // argument to OnInvalidatorStateChange().
44 // 54 //
45 // It is an error to have registered handlers when an InvalidationFrontend is 55 // It is an error to have registered handlers when an
46 // shut down; clients must ensure that they unregister themselves before then. 56 // InvalidationFrontend is shut down; clients must ensure that they
47 // 57 // unregister themselves before then. (Depending on the
48 // TODO(rlarocque): This class should extend BrowserContextKeyedService. 58 // InvalidationFrontend, shutdown may be equivalent to destruction, or
59 // a separate function call like Shutdown()).
49 // 60 //
50 // NOTE(akalin): Invalidations that come in during browser shutdown may get 61 // 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 62 // dropped. This won't matter once we have an Acknowledge API, though: see
52 // http://crbug.com/78462 and http://crbug.com/124149. 63 // http://crbug.com/78462 and http://crbug.com/124149.
53 class InvalidationFrontend { 64 //
65 // This class inherits from ProfileKeyedService to make it possible to correctly
66 // cast from various InvalidationService implementations to ProfileKeyedService
67 // in InvalidationServiceFactory.
68 class InvalidationService : public BrowserContextKeyedService {
54 public: 69 public:
55 // Starts sending notifications to |handler|. |handler| must not be NULL, 70 // Starts sending notifications to |handler|. |handler| must not be NULL,
56 // and it must not already be registered. 71 // and it must not already be registered.
57 // 72 //
58 // Handler registrations are persisted across restarts of sync. 73 // Handler registrations are persisted across restarts of sync.
59 virtual void RegisterInvalidationHandler( 74 virtual void RegisterInvalidationHandler(
60 syncer::InvalidationHandler* handler) = 0; 75 syncer::InvalidationHandler* handler) = 0;
61 76
62 // Updates the set of ObjectIds associated with |handler|. |handler| must 77 // 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 78 // not be NULL, and must already be registered. An ID must be registered for
(...skipping 15 matching lines...) Expand all
79 // Sends an acknowledgement that an invalidation for |id| was successfully 94 // Sends an acknowledgement that an invalidation for |id| was successfully
80 // handled. 95 // handled.
81 virtual void AcknowledgeInvalidation(const invalidation::ObjectId& id, 96 virtual void AcknowledgeInvalidation(const invalidation::ObjectId& id,
82 const syncer::AckHandle& ack_handle) = 0; 97 const syncer::AckHandle& ack_handle) = 0;
83 98
84 // Returns the current invalidator state. When called from within 99 // Returns the current invalidator state. When called from within
85 // InvalidationHandler::OnInvalidatorStateChange(), this must return 100 // InvalidationHandler::OnInvalidatorStateChange(), this must return
86 // the updated state. 101 // the updated state.
87 virtual syncer::InvalidatorState GetInvalidatorState() const = 0; 102 virtual syncer::InvalidatorState GetInvalidatorState() const = 0;
88 103
104 // Returns the ID belonging to this invalidation client. Can be used to
105 // prevent the receipt of notifications of our own changes.
106 virtual std::string GetInvalidatorClientId() const = 0;
107
89 protected: 108 protected:
90 virtual ~InvalidationFrontend() { } 109 virtual ~InvalidationService() { }
91 }; 110 };
92 111
93 } // namespace invalidation 112 } // namespace invalidation
94 113
95 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_FRONTEND_H_ 114 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698