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