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

Side by Side Diff: components/invalidation/public/object_id_invalidation_map.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/invalidation/public/object_id_invalidation_map.h" 5 #include "components/invalidation/public/object_id_invalidation_map.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const ObjectIdInvalidationMap& other) const { 83 const ObjectIdInvalidationMap& other) const {
84 return map_ == other.map_; 84 return map_ == other.map_;
85 } 85 }
86 86
87 std::unique_ptr<base::ListValue> ObjectIdInvalidationMap::ToValue() const { 87 std::unique_ptr<base::ListValue> ObjectIdInvalidationMap::ToValue() const {
88 std::unique_ptr<base::ListValue> value(new base::ListValue()); 88 std::unique_ptr<base::ListValue> value(new base::ListValue());
89 for (IdToListMap::const_iterator it1 = map_.begin(); 89 for (IdToListMap::const_iterator it1 = map_.begin();
90 it1 != map_.end(); ++it1) { 90 it1 != map_.end(); ++it1) {
91 for (SingleObjectInvalidationSet::const_iterator it2 = 91 for (SingleObjectInvalidationSet::const_iterator it2 =
92 it1->second.begin(); it2 != it1->second.end(); ++it2) { 92 it1->second.begin(); it2 != it1->second.end(); ++it2) {
93 value->Append(it2->ToValue().release()); 93 value->Append(it2->ToValue());
94 } 94 }
95 } 95 }
96 return value; 96 return value;
97 } 97 }
98 98
99 bool ObjectIdInvalidationMap::ResetFromValue(const base::ListValue& value) { 99 bool ObjectIdInvalidationMap::ResetFromValue(const base::ListValue& value) {
100 map_.clear(); 100 map_.clear();
101 for (size_t i = 0; i < value.GetSize(); ++i) { 101 for (size_t i = 0; i < value.GetSize(); ++i) {
102 const base::DictionaryValue* dict; 102 const base::DictionaryValue* dict;
103 if (!value.GetDictionary(i, &dict)) { 103 if (!value.GetDictionary(i, &dict)) {
(...skipping 14 matching lines...) Expand all
118 JSONStringValueSerializer serializer(&output); 118 JSONStringValueSerializer serializer(&output);
119 serializer.set_pretty_print(true); 119 serializer.set_pretty_print(true);
120 serializer.Serialize(*ToValue().get()); 120 serializer.Serialize(*ToValue().get());
121 return output; 121 return output;
122 } 122 }
123 123
124 ObjectIdInvalidationMap::ObjectIdInvalidationMap(const IdToListMap& map) 124 ObjectIdInvalidationMap::ObjectIdInvalidationMap(const IdToListMap& map)
125 : map_(map) {} 125 : map_(map) {}
126 126
127 } // namespace syncer 127 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698