OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef REMOTING_HOST_POLICY_HACK_POLICY_SERVICE_WATCHER_H_ | |
6 #define REMOTING_HOST_POLICY_HACK_POLICY_SERVICE_WATCHER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/single_thread_task_runner.h" | |
Sergey Ulanov
2015/01/23 18:29:11
nit: SingleThreadTaskRunner can be forward-declare
Łukasz Anforowicz
2015/01/23 19:24:45
Done.
| |
12 #include "components/policy/core/common/policy_service.h" | |
13 #include "remoting/host/policy_hack/policy_watcher.h" | |
14 | |
15 namespace policy { | |
16 class AsyncPolicyLoader; | |
17 class ConfigurationPolicyProvider; | |
18 class SchemaRegistry; | |
19 } // namespace policy | |
20 | |
21 namespace remoting { | |
22 namespace policy_hack { | |
Sergey Ulanov
2015/01/23 18:29:11
not related to this CL: I think we will want to re
Łukasz Anforowicz
2015/01/23 19:24:45
I plan to do this in the last changelist :-) (I h
| |
23 | |
24 // TODO(lukasza): Merge PolicyServiceWatcher with PolicyWatcher class. | |
25 | |
26 // PolicyServiceWatcher is a concrete implementation of PolicyWatcher that wraps | |
27 // an instance of PolicyService. | |
28 class PolicyServiceWatcher : public PolicyWatcher, | |
29 public policy::PolicyService::Observer { | |
30 public: | |
31 // Constructor for the case when |policy_service| is borrowed. | |
32 // | |
33 // |policy_service_task_runner| is the task runner where it is safe | |
34 // to call |policy_service| methods and where we expect to get callbacks | |
35 // from |policy_service|. | |
36 PolicyServiceWatcher(const scoped_refptr<base::SingleThreadTaskRunner>& | |
37 policy_service_task_runner, | |
38 policy::PolicyService* policy_service); | |
39 | |
40 // Constructor for the case when |policy_service| is owned (and uses also | |
41 // owned |owned_policy_provider| and |owned_schema_registry|. | |
42 // | |
43 // |policy_service_task_runner| is the task runner where it is safe | |
44 // to call |policy_service| methods and where we expect to get callbacks | |
45 // from |policy_service|. | |
46 PolicyServiceWatcher( | |
47 const scoped_refptr<base::SingleThreadTaskRunner>& | |
48 policy_service_task_runner, | |
49 scoped_ptr<policy::PolicyService> owned_policy_service, | |
50 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider, | |
51 scoped_ptr<policy::SchemaRegistry> owned_schema_registry); | |
52 | |
53 ~PolicyServiceWatcher() override; | |
54 | |
55 // Creates PolicyServiceWatcher that wraps the owned |async_policy_loader| | |
56 // with an appropriate PolicySchema. | |
57 // | |
58 // |policy_service_task_runner| is passed through to the constructor | |
59 // of PolicyServiceWatcher. | |
60 static scoped_ptr<PolicyServiceWatcher> CreateFromPolicyLoader( | |
61 const scoped_refptr<base::SingleThreadTaskRunner>& | |
62 policy_service_task_runner, | |
63 scoped_ptr<policy::AsyncPolicyLoader> async_policy_loader); | |
64 | |
65 // PolicyService::Observer interface. | |
66 void OnPolicyUpdated(const policy::PolicyNamespace& ns, | |
67 const policy::PolicyMap& previous, | |
68 const policy::PolicyMap& current) override; | |
69 void OnPolicyServiceInitialized(policy::PolicyDomain domain) override; | |
70 | |
71 protected: | |
72 // PolicyWatcher overrides. | |
73 void StartWatchingInternal() override; | |
74 void StopWatchingInternal() override; | |
75 | |
76 private: | |
77 policy::PolicyService* policy_service_; | |
78 | |
79 // Order of fields below is important to ensure destruction takes object | |
80 // dependencies into account: | |
81 // - |owned_policy_service_| uses |owned_policy_provider_| | |
82 // - |owned_policy_provider_| uses |owned_schema_registry_| | |
83 scoped_ptr<policy::SchemaRegistry> owned_schema_registry_; | |
84 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider_; | |
85 scoped_ptr<policy::PolicyService> owned_policy_service_; | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(PolicyServiceWatcher); | |
88 }; | |
89 | |
90 } // namespace policy_hack | |
91 } // namespace remoting | |
92 | |
93 #endif // REMOTING_HOST_POLICY_HACK_POLICY_SERVICE_WATCHER_H_ | |
OLD | NEW |