Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/external_cache.cc |
| diff --git a/chrome/browser/chromeos/extensions/external_cache.cc b/chrome/browser/chromeos/extensions/external_cache.cc |
| index dabb3b6b40004cfac6ebc22948e5a76259e4d442..976c325f466ea50aea3101a4adb163b5e1c79b73 100644 |
| --- a/chrome/browser/chromeos/extensions/external_cache.cc |
| +++ b/chrome/browser/chromeos/extensions/external_cache.cc |
| @@ -265,7 +265,8 @@ void ExternalCache::CheckCache() { |
| std::string hash; |
| if (local_cache_.GetExtension(it.key(), hash, &file_path, &version)) { |
| // Copy entry to don't modify it inside extensions_. |
| - base::DictionaryValue* entry_copy = entry->DeepCopy(); |
| + std::unique_ptr<base::DictionaryValue> entry_copy = |
| + entry->CreateDeepCopy(); |
| if (extension_urls::IsWebstoreUpdateUrl(GURL(external_update_url))) { |
| entry_copy->SetBoolean( |
| @@ -277,7 +278,7 @@ void ExternalCache::CheckCache() { |
| version); |
| entry_copy->SetString(extensions::ExternalProviderImpl::kExternalCrx, |
| file_path.value()); |
| - cached_extensions_->Set(it.key(), entry_copy); |
| + cached_extensions_->Set(it.key(), std::move(entry_copy)); |
| } else { |
| bool has_external_crx = entry->HasKey( |
| extensions::ExternalProviderImpl::kExternalCrx); |
| @@ -285,7 +286,7 @@ void ExternalCache::CheckCache() { |
| !delegate_->GetInstalledExtensionVersion(it.key()).empty(); |
| if (keep_if_present || has_external_crx || is_already_installed) { |
| // Copy entry to don't modify it inside extensions_. |
| - cached_extensions_->Set(it.key(), entry->DeepCopy()); |
| + cached_extensions_->Set(it.key(), entry->CreateDeepCopy()); |
| } |
| } |
| } |
| @@ -310,14 +311,15 @@ void ExternalCache::OnPutExtension(const std::string& id, |
| VLOG(1) << "ExternalCache installed a new extension in the cache " << id; |
| - base::DictionaryValue* entry = NULL; |
| - if (!extensions_->GetDictionary(id, &entry)) { |
| + base::DictionaryValue* original_entry = NULL; |
| + if (!extensions_->GetDictionary(id, &original_entry)) { |
| LOG(ERROR) << "ExternalCache cannot find entry for extension " << id; |
| return; |
| } |
| - // Copy entry to don't modify it inside extensions_. |
| - entry = entry->DeepCopy(); |
| + // Copy original_entry to don't modify it inside extensions_. |
|
Daniel Erat
2017/03/23 14:21:30
nit: if you want to fix this comment, s/don't/not/
vabr (Chromium)
2017/03/23 22:43:50
Good point!
It still sounded a bit clumsy to me, s
|
| + std::unique_ptr<base::DictionaryValue> entry = |
| + original_entry->CreateDeepCopy(); |
| std::string version; |
| std::string hash; |
| @@ -343,7 +345,7 @@ void ExternalCache::OnPutExtension(const std::string& id, |
| entry->SetString(extensions::ExternalProviderImpl::kExternalCrx, |
| file_path.value()); |
| - cached_extensions_->Set(id, entry); |
| + cached_extensions_->Set(id, std::move(entry)); |
| if (delegate_) |
| delegate_->OnExtensionLoadedInCache(id); |
| UpdateExtensionLoader(); |