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: chrome/browser/extensions/api/storage/managed_value_store_cache.cc

Issue 2825963003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/extensions (Closed)
Patch Set: Created 3 years, 8 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/managed_value_store_cache.h" 5 #include "chrome/browser/extensions/api/storage/managed_value_store_cache.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (!UsesManagedStorage(it->get())) 170 if (!UsesManagedStorage(it->get()))
171 to_remove = (*it)->id(); 171 to_remove = (*it)->id();
172 ++it; 172 ++it;
173 if (!to_remove.empty()) 173 if (!to_remove.empty())
174 added->Remove(to_remove); 174 added->Remove(to_remove);
175 } 175 }
176 176
177 // Load the schema files in a background thread. 177 // Load the schema files in a background thread.
178 BrowserThread::PostBlockingPoolSequencedTask( 178 BrowserThread::PostBlockingPoolSequencedTask(
179 kLoadSchemasBackgroundTaskTokenName, FROM_HERE, 179 kLoadSchemasBackgroundTaskTokenName, FROM_HERE,
180 base::Bind(&ExtensionTracker::LoadSchemasOnBlockingPool, 180 base::BindOnce(&ExtensionTracker::LoadSchemasOnBlockingPool,
181 base::Passed(&added), 181 base::Passed(&added), weak_factory_.GetWeakPtr()));
182 weak_factory_.GetWeakPtr()));
183 } 182 }
184 183
185 bool ManagedValueStoreCache::ExtensionTracker::UsesManagedStorage( 184 bool ManagedValueStoreCache::ExtensionTracker::UsesManagedStorage(
186 const Extension* extension) const { 185 const Extension* extension) const {
187 return extension->manifest()->HasPath(manifest_keys::kStorageManagedSchema); 186 return extension->manifest()->HasPath(manifest_keys::kStorageManagedSchema);
188 } 187 }
189 188
190 // static 189 // static
191 void ManagedValueStoreCache::ExtensionTracker::LoadSchemasOnBlockingPool( 190 void ManagedValueStoreCache::ExtensionTracker::LoadSchemasOnBlockingPool(
192 std::unique_ptr<ExtensionSet> extensions, 191 std::unique_ptr<ExtensionSet> extensions,
(...skipping 16 matching lines...) Expand all
209 policy::Schema schema = 208 policy::Schema schema =
210 StorageSchemaManifestHandler::GetSchema(it->get(), &error); 209 StorageSchemaManifestHandler::GetSchema(it->get(), &error);
211 // If the schema is invalid then proceed with an empty schema. The extension 210 // If the schema is invalid then proceed with an empty schema. The extension
212 // will be listed in chrome://policy but won't be able to load any policies. 211 // will be listed in chrome://policy but won't be able to load any policies.
213 if (!schema.valid()) 212 if (!schema.valid())
214 schema = policy::Schema(); 213 schema = policy::Schema();
215 (*components)[(*it)->id()] = schema; 214 (*components)[(*it)->id()] = schema;
216 } 215 }
217 216
218 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 217 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
219 base::Bind(&ExtensionTracker::Register, self, 218 base::BindOnce(&ExtensionTracker::Register, self,
220 base::Owned(components.release()))); 219 base::Owned(components.release())));
221 } 220 }
222 221
223 void ManagedValueStoreCache::ExtensionTracker::Register( 222 void ManagedValueStoreCache::ExtensionTracker::Register(
224 const policy::ComponentMap* components) { 223 const policy::ComponentMap* components) {
225 DCHECK_CURRENTLY_ON(BrowserThread::UI); 224 DCHECK_CURRENTLY_ON(BrowserThread::UI);
226 schema_registry_->RegisterComponents(policy_domain_, *components); 225 schema_registry_->RegisterComponents(policy_domain_, *components);
227 226
228 // The first SetExtensionsDomainsReady() call is performed after the 227 // The first SetExtensionsDomainsReady() call is performed after the
229 // ExtensionSystem is ready, even if there are no managed extensions. It will 228 // ExtensionSystem is ready, even if there are no managed extensions. It will
230 // trigger a loading of the initial policy for any managed extensions, and 229 // trigger a loading of the initial policy for any managed extensions, and
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 322
324 if (!policy_service_->IsInitializationComplete(policy_domain_)) { 323 if (!policy_service_->IsInitializationComplete(policy_domain_)) {
325 // OnPolicyUpdated is called whenever a policy changes, but it doesn't 324 // OnPolicyUpdated is called whenever a policy changes, but it doesn't
326 // mean that all the policy providers are ready; wait until we get the 325 // mean that all the policy providers are ready; wait until we get the
327 // final policy values before passing them to the store. 326 // final policy values before passing them to the store.
328 return; 327 return;
329 } 328 }
330 329
331 BrowserThread::PostTask( 330 BrowserThread::PostTask(
332 BrowserThread::FILE, FROM_HERE, 331 BrowserThread::FILE, FROM_HERE,
333 base::Bind(&ManagedValueStoreCache::UpdatePolicyOnFILE, 332 base::BindOnce(&ManagedValueStoreCache::UpdatePolicyOnFILE,
334 base::Unretained(this), 333 base::Unretained(this), ns.component_id,
335 ns.component_id, 334 base::Passed(current.DeepCopy())));
336 base::Passed(current.DeepCopy())));
337 } 335 }
338 336
339 // static 337 // static
340 policy::PolicyDomain ManagedValueStoreCache::GetPolicyDomain(Profile* profile) { 338 policy::PolicyDomain ManagedValueStoreCache::GetPolicyDomain(Profile* profile) {
341 #if defined(OS_CHROMEOS) 339 #if defined(OS_CHROMEOS)
342 return chromeos::ProfileHelper::IsSigninProfile(profile) 340 return chromeos::ProfileHelper::IsSigninProfile(profile)
343 ? policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS 341 ? policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS
344 : policy::POLICY_DOMAIN_EXTENSIONS; 342 : policy::POLICY_DOMAIN_EXTENSIONS;
345 #else 343 #else
346 return policy::POLICY_DOMAIN_EXTENSIONS; 344 return policy::POLICY_DOMAIN_EXTENSIONS;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return raw_store; 380 return raw_store;
383 } 381 }
384 382
385 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { 383 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const {
386 // Note: Currently only manage extensions (not apps). 384 // Note: Currently only manage extensions (not apps).
387 return storage_factory_->HasSettings(settings_namespace::MANAGED, 385 return storage_factory_->HasSettings(settings_namespace::MANAGED,
388 kManagedModelType, extension_id); 386 kManagedModelType, extension_id);
389 } 387 }
390 388
391 } // namespace extensions 389 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698