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

Side by Side Diff: tools/json_schema_compiler/util.cc

Issue 2841623003: Remove base::Value::Get{Buffer,Size} (Closed)
Patch Set: Fix SIGSEGV 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "tools/json_schema_compiler/util.h" 5 #include "tools/json_schema_compiler/util.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 base::string16* error) { 65 base::string16* error) {
66 if (!from.GetAsString(out)) 66 if (!from.GetAsString(out))
67 return ReportError(from, base::Value::Type::STRING, error); 67 return ReportError(from, base::Value::Type::STRING, error);
68 return true; 68 return true;
69 } 69 }
70 70
71 bool PopulateItem(const base::Value& from, std::vector<char>* out) { 71 bool PopulateItem(const base::Value& from, std::vector<char>* out) {
72 const base::Value* binary = nullptr; 72 const base::Value* binary = nullptr;
73 if (!from.GetAsBinary(&binary)) 73 if (!from.GetAsBinary(&binary))
74 return false; 74 return false;
75 out->assign(binary->GetBuffer(), binary->GetBuffer() + binary->GetSize()); 75 *out = binary->GetBlob();
76 return true; 76 return true;
77 } 77 }
78 78
79 bool PopulateItem(const base::Value& from, 79 bool PopulateItem(const base::Value& from,
80 std::vector<char>* out, 80 std::vector<char>* out,
81 base::string16* error) { 81 base::string16* error) {
82 const base::Value* binary = nullptr; 82 const base::Value* binary = nullptr;
83 if (!from.GetAsBinary(&binary)) 83 if (!from.GetAsBinary(&binary))
84 return ReportError(from, base::Value::Type::BINARY, error); 84 return ReportError(from, base::Value::Type::BINARY, error);
85 out->assign(binary->GetBuffer(), binary->GetBuffer() + binary->GetSize()); 85 *out = binary->GetBlob();
86 return true; 86 return true;
87 } 87 }
88 88
89 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) { 89 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) {
90 *out = from.CreateDeepCopy(); 90 *out = from.CreateDeepCopy();
91 return true; 91 return true;
92 } 92 }
93 93
94 bool PopulateItem(const base::Value& from, 94 bool PopulateItem(const base::Value& from,
95 std::unique_ptr<base::Value>* out, 95 std::unique_ptr<base::Value>* out,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 out->Append(from->CreateDeepCopy()); 142 out->Append(from->CreateDeepCopy());
143 } 143 }
144 144
145 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, 145 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from,
146 base::ListValue* out) { 146 base::ListValue* out) {
147 out->Append(from->CreateDeepCopy()); 147 out->Append(from->CreateDeepCopy());
148 } 148 }
149 149
150 } // namespace util 150 } // namespace util
151 } // namespace json_schema_compiler 151 } // namespace json_schema_compiler
OLDNEW
« tools/json_schema_compiler/cc_generator.py ('K') | « tools/json_schema_compiler/cc_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698