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

Unified Diff: components/sync/driver/about_sync_util.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 7 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
« no previous file with comments | « components/sync/base/model_type.h ('k') | components/sync/engine/cycle/sync_cycle_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/driver/about_sync_util.cc
diff --git a/components/sync/driver/about_sync_util.cc b/components/sync/driver/about_sync_util.cc
index 054ef74dabe50184c1434be3230c91642647b385..366affcc959a895cb62521db037d3faa42dcceee 100644
--- a/components/sync/driver/about_sync_util.cc
+++ b/components/sync/driver/about_sync_util.cc
@@ -77,10 +77,10 @@ namespace {
// |parent_list|, not the caller, owns the newly added section.
base::ListValue* AddSection(base::ListValue* parent_list,
const std::string& title) {
- std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue());
- base::ListValue* section_contents = new base::ListValue();
+ auto section = base::MakeUnique<base::DictionaryValue>();
section->SetString("title", title);
- section->Set("data", section_contents);
+ base::ListValue* section_contents =
+ section->SetList("data", base::MakeUnique<base::ListValue>());
section->SetBoolean("is_sensitive", false);
// If the following |Append| results in a reallocation, pointers to the
// members of |parent_list| will be invalidated. This would result in
@@ -96,10 +96,10 @@ base::ListValue* AddSection(base::ListValue* parent_list,
// form and posted in a public forum (e.g. unique identifiers).
base::ListValue* AddSensitiveSection(base::ListValue* parent_list,
const std::string& title) {
- std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue());
- base::ListValue* section_contents = new base::ListValue();
+ auto section = base::MakeUnique<base::DictionaryValue>();
section->SetString("title", title);
- section->Set("data", section_contents);
+ base::ListValue* section_contents =
+ section->SetList("data", base::MakeUnique<base::ListValue>());
section->SetBoolean("is_sensitive", true);
// If the following |Append| results in a reallocation, pointers to
// |parent_list| and its members will be invalidated. This would result in
@@ -284,37 +284,38 @@ std::string GetConnectionStatus(const SyncService::SyncTokenStatus& status) {
std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
SyncService* service,
version_info::Channel channel) {
- std::unique_ptr<base::DictionaryValue> about_info(
- new base::DictionaryValue());
+ auto about_info = base::MakeUnique<base::DictionaryValue>();
// 'details': A list of sections.
- base::ListValue* stats_list = new base::ListValue();
+ auto stats_list = base::MakeUnique<base::ListValue>();
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
stats_list->Reserve(12);
// The following lines define the sections and their fields. For each field,
// a class is instantiated, which allows us to reference the fields in
// 'setter' code later on in this function.
- base::ListValue* section_summary = AddSection(stats_list, "Summary");
+ base::ListValue* section_summary = AddSection(stats_list.get(), "Summary");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_summary->Reserve(1);
StringSyncStat summary_string(section_summary, "Summary");
- base::ListValue* section_version = AddSection(stats_list, "Version Info");
+ base::ListValue* section_version =
+ AddSection(stats_list.get(), "Version Info");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_version->Reserve(2);
StringSyncStat client_version(section_version, "Client Version");
StringSyncStat server_url(section_version, "Server URL");
base::ListValue* section_identity =
- AddSensitiveSection(stats_list, kIdentityTitle);
+ AddSensitiveSection(stats_list.get(), kIdentityTitle);
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_identity->Reserve(3);
StringSyncStat sync_id(section_identity, "Sync Client ID");
StringSyncStat invalidator_id(section_identity, "Invalidator Client ID");
StringSyncStat username(section_identity, "Username");
- base::ListValue* section_credentials = AddSection(stats_list, "Credentials");
+ base::ListValue* section_credentials =
+ AddSection(stats_list.get(), "Credentials");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_credentials->Reserve(4);
StringSyncStat request_token_time(section_credentials, "Requested Token");
@@ -323,7 +324,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
"Token Request Status");
StringSyncStat next_token_request(section_credentials, "Next Token Request");
- base::ListValue* section_local = AddSection(stats_list, "Local State");
+ base::ListValue* section_local = AddSection(stats_list.get(), "Local State");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_local->Reserve(7);
StringSyncStat server_connection(section_local, "Server Connection");
@@ -337,7 +338,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
"Local sync backend enabled");
StringSyncStat local_backend_path(section_local, "Local backend path");
- base::ListValue* section_network = AddSection(stats_list, "Network");
+ base::ListValue* section_network = AddSection(stats_list.get(), "Network");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_network->Reserve(3);
BoolSyncStat is_throttled(section_network, "Throttled");
@@ -345,7 +346,8 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
BoolSyncStat are_notifications_enabled(section_network,
"Notifications Enabled");
- base::ListValue* section_encryption = AddSection(stats_list, "Encryption");
+ base::ListValue* section_encryption =
+ AddSection(stats_list.get(), "Encryption");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_encryption->Reserve(9);
BoolSyncStat is_using_explicit_passphrase(section_encryption,
@@ -364,7 +366,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
StringSyncStat passphrase_time(section_encryption, "Passphrase Time");
base::ListValue* section_last_session =
- AddSection(stats_list, "Status from Last Completed Session");
+ AddSection(stats_list.get(), "Status from Last Completed Session");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_last_session->Reserve(4);
StringSyncStat session_source(section_last_session, "Sync Source");
@@ -372,7 +374,8 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
StringSyncStat download_result(section_last_session, "Download Step Result");
StringSyncStat commit_result(section_last_session, "Commit Step Result");
- base::ListValue* section_counters = AddSection(stats_list, "Running Totals");
+ base::ListValue* section_counters =
+ AddSection(stats_list.get(), "Running Totals");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_counters->Reserve(7);
IntSyncStat notifications_received(section_counters,
@@ -387,7 +390,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
"Conflicts Resolved: Server Wins");
base::ListValue* section_this_cycle =
- AddSection(stats_list, "Transient Counters (this cycle)");
+ AddSection(stats_list.get(), "Transient Counters (this cycle)");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_this_cycle->Reserve(4);
IntSyncStat encryption_conflicts(section_this_cycle, "Encryption Conflicts");
@@ -395,8 +398,9 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
IntSyncStat server_conflicts(section_this_cycle, "Server Conflicts");
IntSyncStat committed_items(section_this_cycle, "Committed Items");
- base::ListValue* section_that_cycle = AddSection(
- stats_list, "Transient Counters (last cycle of last completed session)");
+ base::ListValue* section_that_cycle =
+ AddSection(stats_list.get(),
+ "Transient Counters (last cycle of last completed session)");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_that_cycle->Reserve(3);
IntSyncStat updates_downloaded(section_that_cycle, "Updates Downloaded");
@@ -404,7 +408,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
IntSyncStat entries(section_that_cycle, "Entries");
base::ListValue* section_nudge_info =
- AddSection(stats_list, "Nudge Source Counters");
+ AddSection(stats_list.get(), "Nudge Source Counters");
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
section_nudge_info->Reserve(3);
IntSyncStat nudge_source_notification(section_nudge_info,
@@ -414,7 +418,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
// This list of sections belongs in the 'details' field of the returned
// message.
- about_info->Set(kDetailsKey, stats_list);
+ about_info->Set(kDetailsKey, std::move(stats_list));
// Populate all the fields we declared above.
client_version.SetValue(GetVersionString(channel));
@@ -554,15 +558,15 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
// NOTE: We won't bother showing any of the following values unless
// actionable_error_detected is set.
- base::ListValue* actionable_error = new base::ListValue();
+ auto actionable_error = base::MakeUnique<base::ListValue>();
// TODO(crbug.com/702230): Remove the usages of raw pointers in this file.
actionable_error->Reserve(4);
- about_info->Set("actionable_error", actionable_error);
- StringSyncStat error_type(actionable_error, "Error Type");
- StringSyncStat action(actionable_error, "Action");
- StringSyncStat url(actionable_error, "URL");
- StringSyncStat description(actionable_error, "Error Description");
+ StringSyncStat error_type(actionable_error.get(), "Error Type");
+ StringSyncStat action(actionable_error.get(), "Action");
+ StringSyncStat url(actionable_error.get(), "URL");
+ StringSyncStat description(actionable_error.get(), "Error Description");
+ about_info->Set("actionable_error", std::move(actionable_error));
if (actionable_error_detected) {
error_type.SetValue(
« no previous file with comments | « components/sync/base/model_type.h ('k') | components/sync/engine/cycle/sync_cycle_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698