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

Unified Diff: chrome/browser/chromeos/extensions/external_cache.cc

Issue 2765363004: Stop passing raw pointers to DictionaryValue::Set, part 2 (Closed)
Patch Set: Fix comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..52455ea5ba7af57ca6a90bdae0ca57fdad0618c4 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 avoid modifying it inside extensions_.
+ 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();

Powered by Google App Engine
This is Rietveld 408576698