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

Side by Side Diff: components/policy/core/common/fake_async_policy_loader.cc

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 #include "components/policy/core/common/fake_async_policy_loader.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/sequenced_task_runner.h"
10
11 namespace policy {
12
13 FakeAsyncPolicyLoader::FakeAsyncPolicyLoader(
14 scoped_refptr<base::SequencedTaskRunner> task_runner)
15 : AsyncPolicyLoader(task_runner) {
16 }
17
18 scoped_ptr<PolicyBundle> FakeAsyncPolicyLoader::Load() {
19 scoped_ptr<PolicyBundle> result(new PolicyBundle());
20 result->CopyFrom(policy_bundle_);
21 return result.Pass();
22 }
23
24 void FakeAsyncPolicyLoader::InitOnBackgroundThread() {
25 // Nothing to do.
26 }
27
28 void FakeAsyncPolicyLoader::ClearPolicies() {
29 policy_bundle_.Clear();
30 }
31
32 void FakeAsyncPolicyLoader::AddPolicies(const PolicyNamespace& ns,
33 const base::DictionaryValue& policies,
34 PolicyLevel level,
35 PolicyScope scope) {
36 PolicyMap& policy_map = policy_bundle_.Get(ns);
37 policy_map.LoadFrom(&policies, level, scope);
38 }
39
40 void FakeAsyncPolicyLoader::PostReloadOnBackgroundThread(bool force) {
41 task_runner()->PostTask(FROM_HERE, base::Bind(&AsyncPolicyLoader::Reload,
42 base::Unretained(this), force));
43 }
44
45 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698