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

Side by Side Diff: net/cert/ct_log_response_parser.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Created 3 years, 11 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 "net/cert/ct_log_response_parser.h" 5 #include "net/cert/ct_log_response_parser.h"
6 6
7 #include <memory>
8
7 #include "base/base64.h" 9 #include "base/base64.h"
8 #include "base/json/json_value_converter.h" 10 #include "base/json/json_value_converter.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "net/cert/ct_serialization.h" 15 #include "net/cert/ct_serialization.h"
15 #include "net/cert/signed_tree_head.h" 16 #include "net/cert/signed_tree_head.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 namespace ct { 20 namespace ct {
20 21
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DVLOG(1) << "Missing signature from Signed Tree Head JSON."; 99 DVLOG(1) << "Missing signature from Signed Tree Head JSON.";
99 return false; 100 return false;
100 } 101 }
101 102
102 return true; 103 return true;
103 } 104 }
104 105
105 // Structure for making JSON decoding easier. The string fields 106 // Structure for making JSON decoding easier. The string fields
106 // are base64-encoded so will require further decoding. 107 // are base64-encoded so will require further decoding.
107 struct JsonConsistencyProof { 108 struct JsonConsistencyProof {
108 ScopedVector<std::string> proof_nodes; 109 std::vector<std::unique_ptr<std::string>> proof_nodes;
109 110
110 static void RegisterJSONConverter( 111 static void RegisterJSONConverter(
111 base::JSONValueConverter<JsonConsistencyProof>* converter); 112 base::JSONValueConverter<JsonConsistencyProof>* converter);
112 }; 113 };
113 114
114 bool ConvertIndividualProofNode(const base::Value* value, std::string* result) { 115 bool ConvertIndividualProofNode(const base::Value* value, std::string* result) {
115 std::string b64_encoded_node; 116 std::string b64_encoded_node;
116 if (!value->GetAsString(&b64_encoded_node)) 117 if (!value->GetAsString(&b64_encoded_node))
117 return false; 118 return false;
118 119
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 164 }
164 165
165 const base::DictionaryValue* dict_value = NULL; 166 const base::DictionaryValue* dict_value = NULL;
166 if (!json_consistency_proof.GetAsDictionary(&dict_value) || 167 if (!json_consistency_proof.GetAsDictionary(&dict_value) ||
167 !dict_value->HasKey("consistency")) { 168 !dict_value->HasKey("consistency")) {
168 DVLOG(1) << "Missing consistency field."; 169 DVLOG(1) << "Missing consistency field.";
169 return false; 170 return false;
170 } 171 }
171 172
172 consistency_proof->reserve(parsed_proof.proof_nodes.size()); 173 consistency_proof->reserve(parsed_proof.proof_nodes.size());
173 for (std::string* proof_node : parsed_proof.proof_nodes) { 174 for (const auto& proof_node : parsed_proof.proof_nodes) {
174 consistency_proof->push_back(*proof_node); 175 consistency_proof->push_back(*proof_node);
175 } 176 }
176 177
177 return true; 178 return true;
178 } 179 }
179 180
180 } // namespace ct 181 } // namespace ct
181 182
182 } // namespace net 183 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698