| OLD | NEW |
| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 | 341 |
| 342 GetStoreFor(extension_id)->SetCurrentPolicy(*current_policy); | 342 GetStoreFor(extension_id)->SetCurrentPolicy(*current_policy); |
| 343 } | 343 } |
| 344 | 344 |
| 345 PolicyValueStore* ManagedValueStoreCache::GetStoreFor( | 345 PolicyValueStore* ManagedValueStoreCache::GetStoreFor( |
| 346 const std::string& extension_id) { | 346 const std::string& extension_id) { |
| 347 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 347 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 348 | 348 |
| 349 PolicyValueStoreMap::iterator it = store_map_.find(extension_id); | 349 auto it = store_map_.find(extension_id); |
| 350 if (it != store_map_.end()) | 350 if (it != store_map_.end()) |
| 351 return it->second.get(); | 351 return it->second.get(); |
| 352 | 352 |
| 353 // Create the store now, and serve the cached policy until the PolicyService | 353 // Create the store now, and serve the cached policy until the PolicyService |
| 354 // sends updated values. | 354 // sends updated values. |
| 355 PolicyValueStore* store = new PolicyValueStore( | 355 std::unique_ptr<PolicyValueStore> store(new PolicyValueStore( |
| 356 extension_id, observers_, | 356 extension_id, observers_, |
| 357 storage_factory_->CreateSettingsStore(settings_namespace::MANAGED, | 357 storage_factory_->CreateSettingsStore(settings_namespace::MANAGED, |
| 358 kManagedModelType, extension_id)); | 358 kManagedModelType, extension_id))); |
| 359 store_map_[extension_id] = make_linked_ptr(store); | 359 PolicyValueStore* raw_store = store.get(); |
| 360 store_map_[extension_id] = std::move(store); |
| 360 | 361 |
| 361 return store; | 362 return raw_store; |
| 362 } | 363 } |
| 363 | 364 |
| 364 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { | 365 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { |
| 365 // Note: Currently only manage extensions (not apps). | 366 // Note: Currently only manage extensions (not apps). |
| 366 return storage_factory_->HasSettings(settings_namespace::MANAGED, | 367 return storage_factory_->HasSettings(settings_namespace::MANAGED, |
| 367 kManagedModelType, extension_id); | 368 kManagedModelType, extension_id); |
| 368 } | 369 } |
| 369 | 370 |
| 370 } // namespace extensions | 371 } // namespace extensions |
| OLD | NEW |