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

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

Issue 2839753005: Remove base::Value::GetAsBinary (Closed)
Patch Set: ASSERT_TRUE Created 3 years, 8 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 | « mojo/common/values_struct_traits.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 bool PopulateItem(const base::Value& from, 63 bool PopulateItem(const base::Value& from,
64 std::string* out, 64 std::string* out,
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 if (!from.is_blob())
73 if (!from.GetAsBinary(&binary))
74 return false; 73 return false;
75 *out = binary->GetBlob(); 74 *out = from.GetBlob();
76 return true; 75 return true;
77 } 76 }
78 77
79 bool PopulateItem(const base::Value& from, 78 bool PopulateItem(const base::Value& from,
80 std::vector<char>* out, 79 std::vector<char>* out,
81 base::string16* error) { 80 base::string16* error) {
82 const base::Value* binary = nullptr; 81 if (!from.is_blob())
83 if (!from.GetAsBinary(&binary))
84 return ReportError(from, base::Value::Type::BINARY, error); 82 return ReportError(from, base::Value::Type::BINARY, error);
85 *out = binary->GetBlob(); 83 *out = from.GetBlob();
86 return true; 84 return true;
87 } 85 }
88 86
89 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) { 87 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) {
90 *out = from.CreateDeepCopy(); 88 *out = from.CreateDeepCopy();
91 return true; 89 return true;
92 } 90 }
93 91
94 bool PopulateItem(const base::Value& from, 92 bool PopulateItem(const base::Value& from,
95 std::unique_ptr<base::Value>* out, 93 std::unique_ptr<base::Value>* out,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 out->Append(from->CreateDeepCopy()); 140 out->Append(from->CreateDeepCopy());
143 } 141 }
144 142
145 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, 143 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from,
146 base::ListValue* out) { 144 base::ListValue* out) {
147 out->Append(from->CreateDeepCopy()); 145 out->Append(from->CreateDeepCopy());
148 } 146 }
149 147
150 } // namespace util 148 } // namespace util
151 } // namespace json_schema_compiler 149 } // namespace json_schema_compiler
OLDNEW
« no previous file with comments | « mojo/common/values_struct_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698