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

Unified Diff: components/sync/engine_impl/js_mutation_event_observer.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
Index: components/sync/engine_impl/js_mutation_event_observer.cc
diff --git a/components/sync/engine_impl/js_mutation_event_observer.cc b/components/sync/engine_impl/js_mutation_event_observer.cc
index 7b174482100e0aa5b240f09c3f1c650e1d003d44..9dfce0540b9ee9d63e90cc23081d54165927cb6d 100644
--- a/components/sync/engine_impl/js_mutation_event_observer.cc
+++ b/components/sync/engine_impl/js_mutation_event_observer.cc
@@ -5,9 +5,11 @@
#include "components/sync/engine_impl/js_mutation_event_observer.h"
#include <stddef.h>
+#include <utility>
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "components/sync/js/js_event_details.h"
@@ -53,20 +55,20 @@ void JsMutationEventObserver::OnChangesApplied(
details.SetString("modelType", ModelTypeToString(model_type));
details.SetString("writeTransactionId",
base::Int64ToString(write_transaction_id));
- base::Value* changes_value = nullptr;
+ std::unique_ptr<base::Value> changes_value;
const size_t changes_size = changes.Get().size();
if (changes_size <= kChangeLimit) {
- base::ListValue* changes_list = new base::ListValue();
+ auto changes_list = base::MakeUnique<base::ListValue>();
for (ChangeRecordList::const_iterator it = changes.Get().begin();
it != changes.Get().end(); ++it) {
changes_list->Append(it->ToValue());
}
- changes_value = changes_list;
+ changes_value = std::move(changes_list);
} else {
- changes_value =
- new base::Value(base::SizeTToString(changes_size) + " changes");
+ changes_value = base::MakeUnique<base::Value>(
+ base::SizeTToString(changes_size) + " changes");
}
- details.Set("changes", changes_value);
+ details.Set("changes", std::move(changes_value));
HandleJsEvent(FROM_HERE, "onChangesApplied", JsEventDetails(&details));
}
« no previous file with comments | « components/sync/engine/events/protocol_event.cc ('k') | components/sync/engine_impl/js_mutation_event_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698