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/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/policy/core/common/async_policy_loader.h" |
| 12 #include "components/policy/core/common/policy_bundle.h" |
| 13 |
| 14 namespace base { |
| 15 class SequencedTaskRunner; |
| 16 } // namespace base |
| 17 |
| 18 namespace policy { |
| 19 |
| 20 // Fake AsyncPolicyLoader for testing with test-controlled policies. |
| 21 // |
| 22 // Typical test code would populate the policy contents via calls to |
| 23 // ClearPolicies and AddPolicies and then notify the rest of the policy |
| 24 // subsystem of the changes by calling PostReloadOnBackgroundThread. |
| 25 class FakeAsyncPolicyLoader : public AsyncPolicyLoader { |
| 26 public: |
| 27 explicit FakeAsyncPolicyLoader( |
| 28 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 29 |
| 30 // Implementation of virtual methods from AsyncPolicyLoader base class. |
| 31 scoped_ptr<PolicyBundle> Load() override; |
| 32 void InitOnBackgroundThread() override; |
| 33 |
| 34 // Provides content for the simulated / faked policies. |
| 35 void SetPolicies(const PolicyBundle& policy_bundle); |
| 36 |
| 37 // Notifies the rest of the policy subsystem that policy contents have |
| 38 // changed. This simulates / fakes a notification that normally would be |
| 39 // triggered by a FilePathWatcher or (registry)ObjectWatcher in a real loader. |
| 40 // |
| 41 // See AsyncPolicyLoader::Reload method for description of the |force| |
| 42 // parameter. |
| 43 void PostReloadOnBackgroundThread(bool force); |
| 44 |
| 45 private: |
| 46 PolicyBundle policy_bundle_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(FakeAsyncPolicyLoader); |
| 49 }; |
| 50 |
| 51 } // namespace policy |
| 52 |
| 53 #endif // COMPONENTS_POLICY_CORE_COMMON_FAKE_ASYNC_POLICY_LOADER_H_ |
OLD | NEW |