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

Side by Side Diff: chrome/browser/extensions/api/storage/policy_value_store.cc

Issue 2965153002: Migrate Extensions code to Task Scheduler API (Closed)
Patch Set: Self review Created 3 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/api/storage/policy_value_store.h" 5 #include "chrome/browser/extensions/api/storage/policy_value_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/policy/core/common/policy_map.h" 11 #include "components/policy/core/common/policy_map.h"
12 #include "components/policy/core/common/policy_types.h" 12 #include "components/policy/core/common/policy_types.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "extensions/browser/api/storage/backend_task_runner.h"
14 #include "extensions/browser/api/storage/settings_namespace.h" 14 #include "extensions/browser/api/storage/settings_namespace.h"
15 #include "extensions/browser/value_store/value_store_change.h" 15 #include "extensions/browser/value_store/value_store_change.h"
16 16
17 using content::BrowserThread;
18
19 namespace extensions { 17 namespace extensions {
20 18
21 namespace { 19 namespace {
22 20
23 ValueStore::Status ReadOnlyError() { 21 ValueStore::Status ReadOnlyError() {
24 return ValueStore::Status(ValueStore::READ_ONLY, 22 return ValueStore::Status(ValueStore::READ_ONLY,
25 "This is a read-only store."); 23 "This is a read-only store.");
26 } 24 }
27 25
28 } // namespace 26 } // namespace
29 27
30 PolicyValueStore::PolicyValueStore( 28 PolicyValueStore::PolicyValueStore(
31 const std::string& extension_id, 29 const std::string& extension_id,
32 const scoped_refptr<SettingsObserverList>& observers, 30 const scoped_refptr<SettingsObserverList>& observers,
33 std::unique_ptr<ValueStore> delegate) 31 std::unique_ptr<ValueStore> delegate)
34 : extension_id_(extension_id), 32 : extension_id_(extension_id),
35 observers_(observers), 33 observers_(observers),
36 delegate_(std::move(delegate)) {} 34 delegate_(std::move(delegate)) {}
37 35
38 PolicyValueStore::~PolicyValueStore() {} 36 PolicyValueStore::~PolicyValueStore() {}
39 37
40 void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) { 38 void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) {
41 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 39 DCHECK(IsOnBackendSequence());
42 // Convert |policy| to a dictionary value. Only include mandatory policies 40 // Convert |policy| to a dictionary value. Only include mandatory policies
43 // for now. 41 // for now.
44 base::DictionaryValue current_policy; 42 base::DictionaryValue current_policy;
45 for (policy::PolicyMap::const_iterator it = policy.begin(); 43 for (policy::PolicyMap::const_iterator it = policy.begin();
46 it != policy.end(); ++it) { 44 it != policy.end(); ++it) {
47 if (it->second.level == policy::POLICY_LEVEL_MANDATORY) { 45 if (it->second.level == policy::POLICY_LEVEL_MANDATORY) {
48 current_policy.SetWithoutPathExpansion( 46 current_policy.SetWithoutPathExpansion(
49 it->first, it->second.value->CreateDeepCopy()); 47 it->first, it->second.value->CreateDeepCopy());
50 } 48 }
51 } 49 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ValueStore::WriteResult PolicyValueStore::Remove( 151 ValueStore::WriteResult PolicyValueStore::Remove(
154 const std::vector<std::string>& keys) { 152 const std::vector<std::string>& keys) {
155 return MakeWriteResult(ReadOnlyError()); 153 return MakeWriteResult(ReadOnlyError());
156 } 154 }
157 155
158 ValueStore::WriteResult PolicyValueStore::Clear() { 156 ValueStore::WriteResult PolicyValueStore::Clear() {
159 return MakeWriteResult(ReadOnlyError()); 157 return MakeWriteResult(ReadOnlyError());
160 } 158 }
161 159
162 } // namespace extensions 160 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698