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

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

Issue 2466523002: Remove some linked_ptr c/b/extension (Closed)
Patch Set: Created 4 years, 1 month 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 store_map_[extension_id] = base::MakeUnique<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);
360 359
361 return store; 360 return store_map_[extension_id].get();
Devlin 2016/11/02 22:25:33 nit: we can save an extra map lookup here by doing
limasdf 2016/11/03 15:29:23 Done.
362 } 361 }
363 362
364 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { 363 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const {
365 // Note: Currently only manage extensions (not apps). 364 // Note: Currently only manage extensions (not apps).
366 return storage_factory_->HasSettings(settings_namespace::MANAGED, 365 return storage_factory_->HasSettings(settings_namespace::MANAGED,
367 kManagedModelType, extension_id); 366 kManagedModelType, extension_id);
368 } 367 }
369 368
370 } // namespace extensions 369 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698