File: affiliated_invalidation_service_provider.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (79 lines) | stat: -rw-r--r-- 3,215 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_ASH_POLICY_INVALIDATION_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_H_
#define CHROME_BROWSER_ASH_POLICY_INVALIDATION_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_H_

namespace invalidation {
class InvalidationService;
}

namespace policy {

// This class provides access to an |InvalidationService| that can be used to
// subscribe to invalidations generated by the device's enrollment domain, e.g.
// policy pushing and remote commands for:
// * the device itself
// * device-local accounts
// * other users affiliated with the enrollment domain
//
// If an affiliated user with a connected invalidation service is logged in,
// that invalidation service will be used to conserve server resources. If there
// are no logged-in users matching these criteria, a device-global
// |InvalidationService| is spun up.
// The class monitors the status of the invalidation services and switches
// between them whenever the service currently in use disconnects or the
// device-global invalidation service can be replaced with another service that
// just connected.
class AffiliatedInvalidationServiceProvider {
 public:
  class Consumer {
   public:
    Consumer();

    Consumer& operator=(const Consumer&) = delete;

    // This method is called when the invalidation service that the consumer
    // should use changes:
    // * If |invalidation_service| is a nullptr, no invalidation service is
    //   currently available for use.
    // * Otherwise, |invalidation_service| is the invalidation service that the
    //   consumer should use. It is guaranteed to be connected. Any previously
    //   provided invalidation services must no longer be used.
    virtual void OnInvalidationServiceSet(
        invalidation::InvalidationService* invalidation_service) = 0;

   protected:
    virtual ~Consumer();
  };

  AffiliatedInvalidationServiceProvider();

  AffiliatedInvalidationServiceProvider& operator=(
      const AffiliatedInvalidationServiceProvider&) = delete;

  virtual ~AffiliatedInvalidationServiceProvider();

  // Indicates that |consumer| is interested in using the shared
  // |InvalidationService|. The consumer's OnInvalidationServiceSet() method
  // will be called back when a connected invalidation service becomes
  // available. If an invalidation service is available already, the callback
  // will occur synchronously. The |consumer| must be unregistered before |this|
  // is destroyed.
  virtual void RegisterConsumer(Consumer* consumer) = 0;

  // Indicates that |consumer| is no longer interested in using the
  // shared |InvalidationService|.
  virtual void UnregisterConsumer(Consumer* consumer) = 0;

  // Shuts down the provider. Once the provider is shut down, it no longer makes
  // any invalidation service available to consumers, no longer observes any
  // per-profile invalidation services and no longer maintains a device-global
  // invalidation service.
  virtual void Shutdown() = 0;
};

}  // namespace policy

#endif  // CHROME_BROWSER_ASH_POLICY_INVALIDATION_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_H_