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

Side by Side Diff: chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl.h

Issue 822523003: Implement device-local account policy pushing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_2_442800_switch_device_cloud_policy_invalidator
Patch Set: Rebased. Created 5 years, 10 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 2015 The Chromium Authors. All rights reserved. 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 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_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_ H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_ IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_ H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVIDER_ IMPL_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/chromeos/policy/affiliated_invalidation_service_provide r.h"
12 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
14 15
15 namespace invalidation { 16 namespace invalidation {
16 class InvalidationService; 17 class InvalidationService;
17 class TiclInvalidationService; 18 class TiclInvalidationService;
18 } 19 }
19 20
20 namespace policy { 21 namespace policy {
21 22
22 // This class provides access to an |InvalidationService| that can be used to 23 class AffiliatedInvalidationServiceProviderImpl
23 // subscribe to invalidations generated by the device's enrollment domain, e.g. 24 : public AffiliatedInvalidationServiceProvider,
24 // policy pushing and remote commands for: 25 public content::NotificationObserver {
25 // * the device itself
26 // * device-local accounts
27 // * other users affiliated with the enrollment domain
28 //
29 // If an affiliated user with a connected invalidation service is logged in,
30 // that invalidation service will be used to conserve server resources. If there
31 // are no logged-in users matching these criteria, a device-global
32 // |TiclInvalidationService| is spun up.
33 // The class monitors the status of the invalidation services and switches
34 // between them whenever the service currently in use disconnects or the
35 // device-global invalidation service can be replaced with another service that
36 // just connected.
37 class AffiliatedInvalidationServiceProvider
38 : public content::NotificationObserver {
39 public: 26 public:
40 class Consumer { 27 AffiliatedInvalidationServiceProviderImpl();
41 public: 28 ~AffiliatedInvalidationServiceProviderImpl() override;
42 // This method is called when the invalidation service that the consumer
43 // should use changes:
44 // * If |invalidation_service| is a nullptr, no invalidation service is
45 // currently available for use.
46 // * Otherwise, |invalidation_service| is the invalidation service that the
47 // consumer should use. It is guaranteed to be connected. Any previously
48 // provided invalidation services must no longer be used.
49 virtual void OnInvalidationServiceSet(
50 invalidation::InvalidationService* invalidation_service) = 0;
51
52 protected:
53 virtual ~Consumer();
54 };
55
56 AffiliatedInvalidationServiceProvider();
57 ~AffiliatedInvalidationServiceProvider() override;
58 29
59 // content::NotificationObserver: 30 // content::NotificationObserver:
60 void Observe(int type, 31 void Observe(int type,
61 const content::NotificationSource& source, 32 const content::NotificationSource& source,
62 const content::NotificationDetails& details) override; 33 const content::NotificationDetails& details) override;
63 34
64 // Indicates that |consumer| is interested in using the shared 35 // AffiliatedInvalidationServiceProvider:
65 // |InvalidationService|. The consumer's OnInvalidationServiceSet() method 36 void RegisterConsumer(Consumer* consumer) override;
66 // will be called back when a connected invalidation service becomes 37 void UnregisterConsumer(Consumer* consumer) override;
67 // available. If an invalidation service is available already, the callback 38 void Shutdown() override;
68 // will occur synchronously. The |consumer| must be unregistered before |this|
69 // is destroyed.
70 void RegisterConsumer(Consumer* consumer);
71
72 // Indicates that |consumer| is no longer interested in using the
73 // shared |InvalidationService|.
74 void UnregisterConsumer(Consumer* consumer);
75
76 // Shuts down the provider. Once the provider is shut down, it no longer makes
77 // any invalidation service available to consumers, no longer observes any
78 // per-profile invalidation services and no longer maintains a device-global
79 // invalidation service.
80 void Shutdown();
81 39
82 invalidation::TiclInvalidationService* 40 invalidation::TiclInvalidationService*
83 GetDeviceInvalidationServiceForTest() const; 41 GetDeviceInvalidationServiceForTest() const;
84 42
85 private: 43 private:
86 // Helper that monitors the status of a single |InvalidationService|. 44 // Helper that monitors the status of a single |InvalidationService|.
87 class InvalidationServiceObserver; 45 class InvalidationServiceObserver;
88 46
89 // Status updates received from |InvalidationServiceObserver|s. 47 // Status updates received from |InvalidationServiceObserver|s.
90 void OnInvalidationServiceConnected( 48 void OnInvalidationServiceConnected(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // The invalidation service currently used by consumers. nullptr if there are 83 // The invalidation service currently used by consumers. nullptr if there are
126 // no registered consumers or no connected invalidation service is available 84 // no registered consumers or no connected invalidation service is available
127 // for use. 85 // for use.
128 invalidation::InvalidationService* invalidation_service_; 86 invalidation::InvalidationService* invalidation_service_;
129 87
130 ObserverList<Consumer, true> consumers_; 88 ObserverList<Consumer, true> consumers_;
131 int consumer_count_; 89 int consumer_count_;
132 90
133 bool is_shut_down_; 91 bool is_shut_down_;
134 92
135 DISALLOW_COPY_AND_ASSIGN(AffiliatedInvalidationServiceProvider); 93 DISALLOW_COPY_AND_ASSIGN(AffiliatedInvalidationServiceProviderImpl);
136 }; 94 };
137 95
138 } // namespace policy 96 } // namespace policy
139 97
140 #endif // CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVID ER_H_ 98 #endif // CHROME_BROWSER_CHROMEOS_POLICY_AFFILIATED_INVALIDATION_SERVICE_PROVID ER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698