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