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

Unified Diff: base/json/json_parser.cc

Issue 2516363005: Inline StringValue into base::Value (Closed)
Patch Set: GetString by ref and TestStringValue Fix Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/values.h » ('j') | base/values.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_parser.cc
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc
index 1850a1a3f66e2dc4814235c75d3b8190bef794f9..71de23033be0e5cc61fa6dfbd6bd97e09ec2ef0d 100644
--- a/base/json/json_parser.cc
+++ b/base/json/json_parser.cc
@@ -142,6 +142,12 @@ class JSONStringValue : public Value {
explicit JSONStringValue(StringPiece piece)
: Value(Type::STRING), string_piece_(piece) {}
+ ~JSONStringValue() override {
+ // Ugly hack that prevents ~Value() from trying to destroy string_value_.
+ // TODO(crbug.com/646113): Clean this up when StringValue will be removed.
+ type_ = Type::NONE;
+ }
+
// Overridden from Value:
bool GetAsString(std::string* out_value) const override {
string_piece_.CopyToString(out_value);
@@ -151,6 +157,12 @@ class JSONStringValue : public Value {
*out_value = UTF8ToUTF16(string_piece_);
return true;
}
+ // base::Value::GetAsString contains a proper implementation now, so the old
+ // behavior is copied here.
+ // TODO(crbug.com/646113): Clean this up when StringValue will be removed.
+ bool GetAsString(const StringValue** out_value) const override {
+ return false;
+ }
Value* DeepCopy() const override { return new StringValue(string_piece_); }
bool Equals(const Value* other) const override {
std::string other_string;
« no previous file with comments | « no previous file | base/values.h » ('j') | base/values.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698