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

Side by Side Diff: sync/test/fake_server/fake_server_verifier.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 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 unified diff | Download patch
« no previous file with comments | « services/catalog/instance.cc ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/test/fake_server/fake_server_verifier.h" 5 #include "sync/test/fake_server/fake_server_verifier.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 std::unique_ptr<base::DictionaryValue> entities = 103 std::unique_ptr<base::DictionaryValue> entities =
104 fake_server_->GetEntitiesAsDictionaryValue(); 104 fake_server_->GetEntitiesAsDictionaryValue();
105 if (!entities.get()) { 105 if (!entities.get()) {
106 return DictionaryCreationAssertionFailure(); 106 return DictionaryCreationAssertionFailure();
107 } 107 }
108 108
109 string model_type_string = ModelTypeToString(model_type); 109 string model_type_string = ModelTypeToString(model_type);
110 base::ListValue* entity_list = NULL; 110 base::ListValue* entity_list = NULL;
111 size_t actual_count = 0; 111 size_t actual_count = 0;
112 if (entities->GetList(model_type_string, &entity_list)) { 112 if (entities->GetList(model_type_string, &entity_list)) {
113 std::unique_ptr<base::Value> name_value(new base::StringValue(name)); 113 base::StringValue name_value(name);
114 for (base::ListValue::const_iterator it = entity_list->begin(); 114 for (const auto& entity : *entity_list) {
115 it != entity_list->end(); ++it) { 115 if (name_value.Equals(entity.get()))
116 if (name_value->Equals(*it)) {
117 actual_count++; 116 actual_count++;
118 }
119 } 117 }
120 } 118 }
121 119
122 if (!entity_list) { 120 if (!entity_list) {
123 return UnknownTypeAssertionFailure(model_type_string); 121 return UnknownTypeAssertionFailure(model_type_string);
124 } else if (actual_count != expected_count) { 122 } else if (actual_count != expected_count) {
125 return VerificationCountAssertionFailure(actual_count, expected_count) 123 return VerificationCountAssertionFailure(actual_count, expected_count)
126 << "; Name: " 124 << "; Name: "
127 << name 125 << name
128 << "\n\n" 126 << "\n\n"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return AssertionFailure() << "Malformed data: Tab entity not found."; 180 return AssertionFailure() << "Malformed data: Tab entity not found.";
183 } 181 }
184 tab_urls.insert(tab_ids_to_urls[tab_id]); 182 tab_urls.insert(tab_ids_to_urls[tab_id]);
185 } 183 }
186 actual_sessions.AddWindow(tab_urls); 184 actual_sessions.AddWindow(tab_urls);
187 } 185 }
188 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions); 186 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions);
189 } 187 }
190 188
191 } // namespace fake_server 189 } // namespace fake_server
OLDNEW
« no previous file with comments | « services/catalog/instance.cc ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698