Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / invalidation / invalidation_service.h
blobd964f79a151dbc574ba66d1f2cd2d7ef65937e97
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_
8 #include "base/callback_forward.h"
9 #include "components/keyed_service/core/keyed_service.h"
10 #include "sync/notifier/invalidation_util.h"
11 #include "sync/notifier/invalidator_state.h"
13 class IdentityProvider;
15 namespace syncer {
16 class InvalidationHandler;
17 } // namespace syncer
19 namespace invalidation {
20 class InvalidationLogger;
22 // Interface for classes that handle invalidation registrations and send out
23 // invalidations to register handlers.
25 // Invalidation clients should follow the pattern below:
27 // When starting the client:
29 // frontend->RegisterInvalidationHandler(client_handler);
31 // When the set of IDs to register changes for the client during its lifetime
32 // (i.e., between calls to RegisterInvalidationHandler(client_handler) and
33 // UnregisterInvalidationHandler(client_handler):
35 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids);
37 // When shutting down the client for browser shutdown:
39 // frontend->UnregisterInvalidationHandler(client_handler);
41 // Note that there's no call to UpdateRegisteredIds() -- this is because the
42 // invalidation API persists registrations across browser restarts.
44 // When permanently shutting down the client, e.g. when disabling the related
45 // feature:
47 // frontend->UpdateRegisteredInvalidationIds(client_handler, ObjectIdSet());
48 // frontend->UnregisterInvalidationHandler(client_handler);
50 // If an invalidation handler cares about the invalidator state, it should also
51 // do the following when starting the client:
53 // invalidator_state = frontend->GetInvalidatorState();
55 // It can also do the above in OnInvalidatorStateChange(), or it can use the
56 // argument to OnInvalidatorStateChange().
58 // It is an error to have registered handlers when an
59 // InvalidationFrontend is shut down; clients must ensure that they
60 // unregister themselves before then. (Depending on the
61 // InvalidationFrontend, shutdown may be equivalent to destruction, or
62 // a separate function call like Shutdown()).
64 // NOTE(akalin): Invalidations that come in during browser shutdown may get
65 // dropped. This won't matter once we have an Acknowledge API, though: see
66 // http://crbug.com/78462 and http://crbug.com/124149.
68 // This class inherits from ProfileKeyedService to make it possible to correctly
69 // cast from various InvalidationService implementations to ProfileKeyedService
70 // in InvalidationServiceFactory.
71 class InvalidationService : public KeyedService {
72 public:
73 // Starts sending notifications to |handler|. |handler| must not be NULL,
74 // and it must not already be registered.
76 // Handler registrations are persisted across restarts of sync.
77 virtual void RegisterInvalidationHandler(
78 syncer::InvalidationHandler* handler) = 0;
80 // Updates the set of ObjectIds associated with |handler|. |handler| must
81 // not be NULL, and must already be registered. An ID must be registered for
82 // at most one handler.
84 // Registered IDs are persisted across restarts of sync.
85 virtual void UpdateRegisteredInvalidationIds(
86 syncer::InvalidationHandler* handler,
87 const syncer::ObjectIdSet& ids) = 0;
89 // Stops sending notifications to |handler|. |handler| must not be NULL, and
90 // it must already be registered. Note that this doesn't unregister the IDs
91 // associated with |handler|.
93 // Handler registrations are persisted across restarts of sync.
94 virtual void UnregisterInvalidationHandler(
95 syncer::InvalidationHandler* handler) = 0;
97 // Returns the current invalidator state. When called from within
98 // InvalidationHandler::OnInvalidatorStateChange(), this must return
99 // the updated state.
100 virtual syncer::InvalidatorState GetInvalidatorState() const = 0;
102 // Returns the ID belonging to this invalidation client. Can be used to
103 // prevent the receipt of notifications of our own changes.
104 virtual std::string GetInvalidatorClientId() const = 0;
106 // Return the logger used to debug invalidations
107 virtual InvalidationLogger* GetInvalidationLogger() = 0;
109 // Triggers requests of internal status.
110 virtual void RequestDetailedStatus(
111 base::Callback<void(const base::DictionaryValue&)> post_caller) const = 0;
113 // Returns the identity provider.
114 virtual IdentityProvider* GetIdentityProvider() = 0;
116 protected:
117 virtual ~InvalidationService() { }
120 } // namespace invalidation
122 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_H_