1 // Copyright 2015 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_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_H_
8 #include "base/macros.h"
10 namespace invalidation
{
11 class InvalidationService
;
16 // This class provides access to an |InvalidationService| that can be used to
17 // subscribe to invalidations generated by the device's enrollment domain, e.g.
18 // policy pushing and remote commands for:
19 // * the device itself
20 // * device-local accounts
21 // * other users affiliated with the enrollment domain
23 // If an affiliated user with a connected invalidation service is logged in,
24 // that invalidation service will be used to conserve server resources. If there
25 // are no logged-in users matching these criteria, a device-global
26 // |TiclInvalidationService| is spun up.
27 // The class monitors the status of the invalidation services and switches
28 // between them whenever the service currently in use disconnects or the
29 // device-global invalidation service can be replaced with another service that
31 class AffiliatedInvalidationServiceProvider
{
37 // This method is called when the invalidation service that the consumer
38 // should use changes:
39 // * If |invalidation_service| is a nullptr, no invalidation service is
40 // currently available for use.
41 // * Otherwise, |invalidation_service| is the invalidation service that the
42 // consumer should use. It is guaranteed to be connected. Any previously
43 // provided invalidation services must no longer be used.
44 virtual void OnInvalidationServiceSet(
45 invalidation::InvalidationService
* invalidation_service
) = 0;
50 DISALLOW_ASSIGN(Consumer
);
53 AffiliatedInvalidationServiceProvider();
54 virtual ~AffiliatedInvalidationServiceProvider();
56 // Indicates that |consumer| is interested in using the shared
57 // |InvalidationService|. The consumer's OnInvalidationServiceSet() method
58 // will be called back when a connected invalidation service becomes
59 // available. If an invalidation service is available already, the callback
60 // will occur synchronously. The |consumer| must be unregistered before |this|
62 virtual void RegisterConsumer(Consumer
* consumer
) = 0;
64 // Indicates that |consumer| is no longer interested in using the
65 // shared |InvalidationService|.
66 virtual void UnregisterConsumer(Consumer
* consumer
) = 0;
68 // Shuts down the provider. Once the provider is shut down, it no longer makes
69 // any invalidation service available to consumers, no longer observes any
70 // per-profile invalidation services and no longer maintains a device-global
71 // invalidation service.
72 virtual void Shutdown() = 0;
75 DISALLOW_ASSIGN(AffiliatedInvalidationServiceProvider
);
80 #endif // CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_H_