Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / invalidation / impl / invalidator.h
blob6fcdbe27be9383a9ba1743d5f7a7669b9d399762
1 // Copyright 2014 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 // Interface to the invalidator, which is an object that receives
6 // invalidations for registered object IDs. The corresponding
7 // InvalidationHandler is notifier when such an event occurs.
9 #ifndef COMPONENTS_INVALIDATION_IMPL_INVALIDATOR_H_
10 #define COMPONENTS_INVALIDATION_IMPL_INVALIDATOR_H_
12 #include <string>
14 #include "base/callback.h"
15 #include "components/invalidation/public/invalidation_export.h"
16 #include "components/invalidation/public/invalidation_util.h"
17 #include "components/invalidation/public/invalidator_state.h"
19 namespace syncer {
20 class InvalidationHandler;
22 class INVALIDATION_EXPORT Invalidator {
23 public:
24 Invalidator();
25 virtual ~Invalidator();
27 // Clients should follow the pattern below:
29 // When starting the client:
31 // invalidator->RegisterHandler(client_handler);
33 // When the set of IDs to register changes for the client during its lifetime
34 // (i.e., between calls to RegisterHandler(client_handler) and
35 // UnregisterHandler(client_handler):
37 // invalidator->UpdateRegisteredIds(client_handler, client_ids);
39 // When shutting down the client for profile shutdown:
41 // invalidator->UnregisterHandler(client_handler);
43 // Note that there's no call to UpdateRegisteredIds() -- this is because the
44 // invalidation API persists registrations across browser restarts.
46 // When permanently shutting down the client, e.g. when disabling the related
47 // feature:
49 // invalidator->UpdateRegisteredIds(client_handler, ObjectIdSet());
50 // invalidator->UnregisterHandler(client_handler);
52 // It is an error to have registered handlers when an invalidator is
53 // destroyed; clients must ensure that they unregister themselves
54 // before then.
56 // Starts sending notifications to |handler|. |handler| must not be NULL,
57 // and it must not already be registered.
58 virtual void RegisterHandler(InvalidationHandler* handler) = 0;
60 // Updates the set of ObjectIds associated with |handler|. |handler| must
61 // not be NULL, and must already be registered. An ID must be registered for
62 // at most one handler. If ID is already registered function returns false.
63 virtual bool UpdateRegisteredIds(InvalidationHandler* handler,
64 const ObjectIdSet& ids)
65 WARN_UNUSED_RESULT = 0;
67 // Stops sending notifications to |handler|. |handler| must not be NULL, and
68 // it must already be registered. Note that this doesn't unregister the IDs
69 // associated with |handler|.
70 virtual void UnregisterHandler(InvalidationHandler* handler) = 0;
72 // Returns the current invalidator state. When called from within
73 // InvalidationHandler::OnInvalidatorStateChange(), this must return
74 // the updated state.
75 virtual InvalidatorState GetInvalidatorState() const = 0;
77 // The observers won't be notified of any notifications until
78 // UpdateCredentials is called at least once. It can be called more than
79 // once.
80 virtual void UpdateCredentials(
81 const std::string& email, const std::string& token) = 0;
83 // Requests internal detailed status to be posted back to the callback.
84 virtual void RequestDetailedStatus(
85 base::Callback<void(const base::DictionaryValue&)> callback) const = 0;
87 } // namespace syncer
89 #endif // COMPONENTS_INVALIDATION_IMPL_INVALIDATOR_H_