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

Unified Diff: base/json/json_parser.cc

Issue 2516363005: Inline StringValue into base::Value (Closed)
Patch Set: Rebase and Nits. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/test/values_test_util.h » ('j') | no next file with comments »
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 e85c3d256c4fc1cdd2f59944f5b9c8d270d56593..814b9c42a29fdf24972dbf3085e650cdb571b95a 100644
--- a/base/json/json_parser.cc
+++ b/base/json/json_parser.cc
@@ -144,6 +144,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);
@@ -153,6 +159,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;
+ }
bool GetAsString(StringPiece* out_value) const override {
*out_value = string_piece_;
return true;
« no previous file with comments | « no previous file | base/test/values_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698