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

Side by Side Diff: remoting/host/policy_hack/policy_service_watcher.h

Issue 858303003: Removing FakePolicyWatcher and introducing FakeAsyncPolicyLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
(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/single_thread_task_runner.h"
9 #include "components/policy/core/common/async_policy_loader.h"
10 #include "components/policy/core/common/async_policy_provider.h"
11 #include "components/policy/core/common/policy_namespace.h"
12 #include "components/policy/core/common/policy_service.h"
13 #include "components/policy/core/common/schema.h"
14 #include "components/policy/core/common/schema_registry.h"
Mattias Nissler (ping if slow) 2015/01/22 16:05:07 A lot of these policy dependencies are probably fo
Łukasz Anforowicz 2015/01/22 18:28:06 Done.
15 #include "remoting/host/policy_hack/policy_watcher.h"
16
17 namespace remoting {
18 namespace policy_hack {
19
20 // TODO(lukasza): Merge PolicyServiceWatcher with PolicyWatcher class.
21
22 // PolicyServiceWatcher is a concrete implementation of PolicyWatcher that wraps
23 // an instance of PolicyService.
24 class PolicyServiceWatcher : public PolicyWatcher,
25 public policy::PolicyService::Observer {
26 public:
27 // Constructor for the case when |policy_service| is borrowed.
28 //
29 // |policy_service_task_runner| is the task runner where it is safe
30 // to call |policy_service| methods and where we expect to get callbacks
31 // from |policy_service|.
32 PolicyServiceWatcher(const scoped_refptr<base::SingleThreadTaskRunner>&
Mattias Nissler (ping if slow) 2015/01/22 16:05:07 #include "base/memory/ref_counted.h"
Łukasz Anforowicz 2015/01/22 18:28:06 Done.
33 policy_service_task_runner,
34 policy::PolicyService* policy_service);
35
36 // Constructor for the case when |policy_service| is owned (and uses also
37 // owned |owned_policy_provider| and |owned_schema_registry|.
38 //
39 // |policy_service_task_runner| is the task runner where it is safe
40 // to call |policy_service| methods and where we expect to get callbacks
41 // from |policy_service|.
42 PolicyServiceWatcher(
43 const scoped_refptr<base::SingleThreadTaskRunner>&
44 policy_service_task_runner,
45 scoped_ptr<policy::PolicyService> owned_policy_service,
Mattias Nissler (ping if slow) 2015/01/22 16:05:07 #include "base/memory/scoped_ptr.h"
Łukasz Anforowicz 2015/01/22 18:28:06 Done.
46 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider,
47 scoped_ptr<policy::SchemaRegistry> owned_schema_registry);
48
49 ~PolicyServiceWatcher() override;
50
51 // Creates PolicyServiceWatcher that wraps the owned |async_policy_loader|
52 // with an appropriate PolicySchema.
53 //
54 // |policy_service_task_runner| is passed through to the constructor
55 // of PolicyServiceWatcher.
56 static scoped_ptr<PolicyServiceWatcher> CreateFromPolicyLoader(
57 const scoped_refptr<base::SingleThreadTaskRunner>&
58 policy_service_task_runner,
59 scoped_ptr<policy::AsyncPolicyLoader> async_policy_loader);
60
61 // PolicyService::Observer interface.
62 void OnPolicyUpdated(const policy::PolicyNamespace& ns,
63 const policy::PolicyMap& previous,
64 const policy::PolicyMap& current) override;
65 void OnPolicyServiceInitialized(policy::PolicyDomain domain) override;
66
67 protected:
68 // PolicyWatcher overrides.
69 void StartWatchingInternal() override;
70 void StopWatchingInternal() override;
71
72 private:
73 policy::PolicyService* policy_service_;
74
75 // Order of fields below is important to ensure destruction takes object
76 // dependencies into account:
77 // - |owned_policy_service_| uses |owned_policy_provider_|
78 // - |owned_policy_provider_| uses |owned_schema_registry_|
79 scoped_ptr<policy::SchemaRegistry> owned_schema_registry_;
80 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider_;
81 scoped_ptr<policy::PolicyService> owned_policy_service_;
82
83 DISALLOW_COPY_AND_ASSIGN(PolicyServiceWatcher);
84 };
85
86 } // namespace policy_hack
87 } // namespace remoting
88
89 #endif // REMOTING_HOST_POLICY_HACK_POLICY_SERVICE_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698