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

Unified Diff: chrome/browser/ui/webui/predictors/predictors_handler.cc

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: No ListValue::SetDouble 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/predictors/predictors_handler.cc
diff --git a/chrome/browser/ui/webui/predictors/predictors_handler.cc b/chrome/browser/ui/webui/predictors/predictors_handler.cc
index bd03c65f205d354fadcc992c19ef796e640646b0..d9dce056699c2e72ac19793b8f2751a516b2ec64 100644
--- a/chrome/browser/ui/webui/predictors/predictors_handler.cc
+++ b/chrome/browser/ui/webui/predictors/predictors_handler.cc
@@ -9,6 +9,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "chrome/browser/predictors/autocomplete_action_predictor.h"
#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
@@ -68,7 +69,7 @@ void PredictorsHandler::RequestAutocompleteActionPredictorDb(
base::DictionaryValue dict;
dict.SetBoolean("enabled", enabled);
if (enabled) {
- base::ListValue* db = new base::ListValue();
+ auto db = base::MakeUnique<base::ListValue>();
for (AutocompleteActionPredictor::DBCacheMap::const_iterator it =
autocomplete_action_predictor_->db_cache_.begin();
it != autocomplete_action_predictor_->db_cache_.end();
@@ -82,7 +83,7 @@ void PredictorsHandler::RequestAutocompleteActionPredictorDb(
autocomplete_action_predictor_->CalculateConfidenceForDbEntry(it));
db->Append(std::move(entry));
}
- dict.Set("db", db);
+ dict.Set("db", std::move(db));
}
web_ui()->CallJavascriptFunctionUnsafe("updateAutocompleteActionPredictorDb",
@@ -97,15 +98,15 @@ void PredictorsHandler::RequestResourcePrefetchPredictorDb(
if (enabled) {
// Url Database cache.
- base::ListValue* db = new base::ListValue();
+ auto db = base::MakeUnique<base::ListValue>();
AddPrefetchDataMapToListValue(
- *resource_prefetch_predictor_->url_table_cache_, db);
- dict.Set("url_db", db);
+ *resource_prefetch_predictor_->url_table_cache_, db.get());
+ dict.Set("url_db", std::move(db));
- db = new base::ListValue();
+ db = base::MakeUnique<base::ListValue>();
AddPrefetchDataMapToListValue(
- *resource_prefetch_predictor_->host_table_cache_, db);
- dict.Set("host_db", db);
+ *resource_prefetch_predictor_->host_table_cache_, db.get());
+ dict.Set("host_db", std::move(db));
}
web_ui()->CallJavascriptFunctionUnsafe("updateResourcePrefetchPredictorDb",
@@ -118,7 +119,7 @@ void PredictorsHandler::AddPrefetchDataMapToListValue(
for (const auto& p : data_map) {
std::unique_ptr<base::DictionaryValue> main(new base::DictionaryValue());
main->SetString("main_frame_url", p.first);
- base::ListValue* resources = new base::ListValue();
+ auto resources = base::MakeUnique<base::ListValue>();
for (const predictors::ResourceData& r : p.second.resources()) {
std::unique_ptr<base::DictionaryValue> resource(
new base::DictionaryValue());
@@ -136,7 +137,7 @@ void PredictorsHandler::AddPrefetchDataMapToListValue(
resource_prefetch_predictor_->IsResourcePrefetchable(r));
resources->Append(std::move(resource));
}
- main->Set("resources", resources);
+ main->Set("resources", std::move(resources));
db->Append(std::move(main));
}
}
« no previous file with comments | « chrome/browser/ui/webui/policy_ui_handler.cc ('k') | chrome/browser/ui/webui/settings/certificates_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698