Chromium Code Reviews| 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 COMPONENTS_POLICY_CORE_COMMON_FAKE_ASYNC_POLICY_LOADER_H_ | |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_FAKE_ASYNC_POLICY_LOADER_H_ | |
| 7 | |
| 8 #include "base/values.h" | |
|
Mattias Nissler (ping if slow)
2015/01/22 16:05:07
nit: you can forward-declare DictionaryValue inste
Łukasz Anforowicz
2015/01/22 18:28:05
Done.
| |
| 9 #include "components/policy/core/common/async_policy_loader.h" | |
| 10 #include "components/policy/core/common/policy_bundle.h" | |
| 11 #include "components/policy/core/common/policy_namespace.h" | |
| 12 #include "components/policy/core/common/policy_types.h" | |
| 13 | |
| 14 namespace policy { | |
| 15 | |
| 16 // Fake AsyncPolicyLoader for testing with test-controlled policies. | |
| 17 // | |
| 18 // Typical test code would populate the policy contents via calls to | |
| 19 // ClearPolicies and AddPolicies and then notify the rest of the policy | |
| 20 // subsystem of the changes by calling PostReloadOnBackgroundThread. | |
| 21 class FakeAsyncPolicyLoader : public AsyncPolicyLoader { | |
| 22 public: | |
| 23 explicit FakeAsyncPolicyLoader( | |
| 24 scoped_refptr<base::SequencedTaskRunner> task_runner); | |
| 25 | |
| 26 // Implementation of virtual methods from AsyncPolicyLoader base class. | |
| 27 scoped_ptr<PolicyBundle> Load() override; | |
| 28 void InitOnBackgroundThread() override; | |
| 29 | |
| 30 // Clears the simulated / faked policy contents. | |
| 31 void ClearPolicies(); | |
|
Mattias Nissler (ping if slow)
2015/01/22 16:05:07
I'd prefer if you just made an UpdatePolicies(cons
Łukasz Anforowicz
2015/01/22 18:28:05
I removed ClearPolicies and AddPolicies(Dict) and
| |
| 32 | |
| 33 // Adds content to the simulated / faked policy contents. | |
| 34 void AddPolicies(const PolicyNamespace& ns, | |
| 35 const base::DictionaryValue& policies, | |
| 36 PolicyLevel level, | |
| 37 PolicyScope scope); | |
| 38 | |
| 39 // Notifies the rest of the policy subsystem that policy contents have | |
| 40 // changed. This simulates / fakes a notification that normally would be | |
| 41 // triggered by a FilePathWatcher or (registry)ObjectWatcher in a real loader. | |
| 42 // | |
| 43 // See AsyncPolicyLoader::Reload method for description of the |force| | |
| 44 // parameter. | |
| 45 void PostReloadOnBackgroundThread(bool force); | |
| 46 | |
| 47 private: | |
| 48 PolicyBundle policy_bundle_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(FakeAsyncPolicyLoader); | |
| 51 }; | |
| 52 | |
| 53 } // namespace policy | |
| 54 | |
| 55 #endif // COMPONENTS_POLICY_CORE_COMMON_FAKE_ASYNC_POLICY_LOADER_H_ | |
| OLD | NEW |