diff options
Diffstat (limited to 'third_party/chromium/base/json')
-rw-r--r-- | third_party/chromium/base/json/json_parser.cc | 82 | ||||
-rw-r--r-- | third_party/chromium/base/json/json_parser.h | 5 | ||||
-rw-r--r-- | third_party/chromium/base/json/json_parser_unittest.cc | 29 | ||||
-rw-r--r-- | third_party/chromium/base/json/json_reader.cc | 27 | ||||
-rw-r--r-- | third_party/chromium/base/json/json_reader.h | 23 | ||||
-rw-r--r-- | third_party/chromium/base/json/json_reader_unittest.cc | 20 | ||||
-rw-r--r-- | third_party/chromium/base/json/json_writer_unittest.cc | 21 |
7 files changed, 109 insertions, 98 deletions
diff --git a/third_party/chromium/base/json/json_parser.cc b/third_party/chromium/base/json/json_parser.cc index 304a7bd..708965a 100644 --- a/third_party/chromium/base/json/json_parser.cc +++ b/third_party/chromium/base/json/json_parser.cc @@ -5,10 +5,11 @@ #include "base/json/json_parser.h" #include <cmath> +#include <utility> #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" @@ -26,16 +27,19 @@ const int kStackMaxDepth = 100; const int32_t kExtendedASCIIStart = 0x80; -// This and the class below are used to own the JSON input string for when -// string tokens are stored as StringPiece instead of std::string. This -// optimization avoids about 2/3rds of string memory copies. The constructor -// takes ownership of the input string. The real root value is Swap()ed into -// the new instance. +// DictionaryHiddenRootValue and ListHiddenRootValue are used in conjunction +// with JSONStringValue as an optimization for reducing the number of string +// copies. When this optimization is active, the parser uses a hidden root to +// keep the original JSON input string live and creates JSONStringValue children +// holding StringPiece references to the input string, avoiding about 2/3rds of +// string memory copies. The real root value is Swap()ed into the new instance. class DictionaryHiddenRootValue : public DictionaryValue { public: - DictionaryHiddenRootValue(std::string* json, Value* root) : json_(json) { + DictionaryHiddenRootValue(std::unique_ptr<std::string> json, + std::unique_ptr<Value> root) + : json_(std::move(json)) { DCHECK(root->IsType(Value::TYPE_DICTIONARY)); - DictionaryValue::Swap(static_cast<DictionaryValue*>(root)); + DictionaryValue::Swap(static_cast<DictionaryValue*>(root.get())); } void Swap(DictionaryValue* other) override { @@ -43,7 +47,7 @@ class DictionaryHiddenRootValue : public DictionaryValue { // First deep copy to convert JSONStringValue to std::string and swap that // copy with |other|, which contains the new contents of |this|. - scoped_ptr<DictionaryValue> copy(DeepCopy()); + std::unique_ptr<DictionaryValue> copy(CreateDeepCopy()); copy->Swap(other); // Then erase the contents of the current dictionary and swap in the @@ -57,7 +61,7 @@ class DictionaryHiddenRootValue : public DictionaryValue { // the method below. bool RemoveWithoutPathExpansion(const std::string& key, - scoped_ptr<Value>* out) override { + std::unique_ptr<Value>* out) override { // If the caller won't take ownership of the removed value, just call up. if (!out) return DictionaryValue::RemoveWithoutPathExpansion(key, out); @@ -66,26 +70,28 @@ class DictionaryHiddenRootValue : public DictionaryValue { // Otherwise, remove the value while its still "owned" by this and copy it // to convert any JSONStringValues to std::string. - scoped_ptr<Value> out_owned; + std::unique_ptr<Value> out_owned; if (!DictionaryValue::RemoveWithoutPathExpansion(key, &out_owned)) return false; - out->reset(out_owned->DeepCopy()); + *out = out_owned->CreateDeepCopy(); return true; } private: - scoped_ptr<std::string> json_; + std::unique_ptr<std::string> json_; DISALLOW_COPY_AND_ASSIGN(DictionaryHiddenRootValue); }; class ListHiddenRootValue : public ListValue { public: - ListHiddenRootValue(std::string* json, Value* root) : json_(json) { + ListHiddenRootValue(std::unique_ptr<std::string> json, + std::unique_ptr<Value> root) + : json_(std::move(json)) { DCHECK(root->IsType(Value::TYPE_LIST)); - ListValue::Swap(static_cast<ListValue*>(root)); + ListValue::Swap(static_cast<ListValue*>(root.get())); } void Swap(ListValue* other) override { @@ -93,7 +99,7 @@ class ListHiddenRootValue : public ListValue { // First deep copy to convert JSONStringValue to std::string and swap that // copy with |other|, which contains the new contents of |this|. - scoped_ptr<ListValue> copy(DeepCopy()); + std::unique_ptr<ListValue> copy(CreateDeepCopy()); copy->Swap(other); // Then erase the contents of the current list and swap in the new contents, @@ -103,7 +109,7 @@ class ListHiddenRootValue : public ListValue { ListValue::Swap(copy.get()); } - bool Remove(size_t index, scoped_ptr<Value>* out) override { + bool Remove(size_t index, std::unique_ptr<Value>* out) override { // If the caller won't take ownership of the removed value, just call up. if (!out) return ListValue::Remove(index, out); @@ -112,17 +118,17 @@ class ListHiddenRootValue : public ListValue { // Otherwise, remove the value while its still "owned" by this and copy it // to convert any JSONStringValues to std::string. - scoped_ptr<Value> out_owned; + std::unique_ptr<Value> out_owned; if (!ListValue::Remove(index, &out_owned)) return false; - out->reset(out_owned->DeepCopy()); + *out = out_owned->CreateDeepCopy(); return true; } private: - scoped_ptr<std::string> json_; + std::unique_ptr<std::string> json_; DISALLOW_COPY_AND_ASSIGN(ListHiddenRootValue); }; @@ -132,10 +138,8 @@ class ListHiddenRootValue : public ListValue { // otherwise the referenced string will not be guaranteed to outlive it. class JSONStringValue : public Value { public: - explicit JSONStringValue(const StringPiece& piece) - : Value(TYPE_STRING), - string_piece_(piece) { - } + explicit JSONStringValue(StringPiece piece) + : Value(TYPE_STRING), string_piece_(piece) {} // Overridden from Value: bool GetAsString(std::string* out_value) const override { @@ -198,13 +202,13 @@ JSONParser::JSONParser(int options) JSONParser::~JSONParser() { } -Value* JSONParser::Parse(const StringPiece& input) { - scoped_ptr<std::string> input_copy; +std::unique_ptr<Value> JSONParser::Parse(StringPiece input) { + std::unique_ptr<std::string> input_copy; // If the children of a JSON root can be detached, then hidden roots cannot // be used, so do not bother copying the input because StringPiece will not // be used anywhere. if (!(options_ & JSON_DETACHABLE_CHILDREN)) { - input_copy.reset(new std::string(input.as_string())); + input_copy = WrapUnique(new std::string(input.as_string())); start_pos_ = input_copy->data(); } else { start_pos_ = input.data(); @@ -230,15 +234,15 @@ Value* JSONParser::Parse(const StringPiece& input) { } // Parse the first and any nested tokens. - scoped_ptr<Value> root(ParseNextToken()); - if (!root.get()) - return NULL; + std::unique_ptr<Value> root(ParseNextToken()); + if (!root) + return nullptr; // Make sure the input stream is at an end. if (GetNextToken() != T_END_OF_INPUT) { if (!CanConsume(1) || (NextChar() && GetNextToken() != T_END_OF_INPUT)) { ReportError(JSONReader::JSON_UNEXPECTED_DATA_AFTER_ROOT, 1); - return NULL; + return nullptr; } } @@ -246,19 +250,21 @@ Value* JSONParser::Parse(const StringPiece& input) { // hidden root. if (!(options_ & JSON_DETACHABLE_CHILDREN)) { if (root->IsType(Value::TYPE_DICTIONARY)) { - return new DictionaryHiddenRootValue(input_copy.release(), root.get()); + return WrapUnique(new DictionaryHiddenRootValue(std::move(input_copy), + std::move(root))); } else if (root->IsType(Value::TYPE_LIST)) { - return new ListHiddenRootValue(input_copy.release(), root.get()); + return WrapUnique( + new ListHiddenRootValue(std::move(input_copy), std::move(root))); } else if (root->IsType(Value::TYPE_STRING)) { // A string type could be a JSONStringValue, but because there's no // corresponding HiddenRootValue, the memory will be lost. Deep copy to // preserve it. - return root->DeepCopy(); + return root->CreateDeepCopy(); } } // All other values can be returned directly. - return root.release(); + return root; } JSONReader::JsonParseError JSONParser::error_code() const { @@ -304,7 +310,7 @@ JSONParser::StringBuilder::~StringBuilder() { void JSONParser::StringBuilder::Append(const char& c) { DCHECK_GE(c, 0); - DCHECK_LT(c, 128); + DCHECK_LT(static_cast<unsigned char>(c), 128); if (string_) string_->push_back(c); @@ -494,7 +500,7 @@ Value* JSONParser::ConsumeDictionary() { return NULL; } - scoped_ptr<DictionaryValue> dict(new DictionaryValue); + std::unique_ptr<DictionaryValue> dict(new DictionaryValue); NextChar(); Token token = GetNextToken(); @@ -558,7 +564,7 @@ Value* JSONParser::ConsumeList() { return NULL; } - scoped_ptr<ListValue> list(new ListValue); + std::unique_ptr<ListValue> list(new ListValue); NextChar(); Token token = GetNextToken(); diff --git a/third_party/chromium/base/json/json_parser.h b/third_party/chromium/base/json/json_parser.h index fc04594..5bdec58 100644 --- a/third_party/chromium/base/json/json_parser.h +++ b/third_party/chromium/base/json/json_parser.h @@ -8,6 +8,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include "base/base_export.h" @@ -50,7 +51,7 @@ class BASE_EXPORT JSONParser { // Parses the input string according to the set options and returns the // result as a Value owned by the caller. - Value* Parse(const StringPiece& input); + std::unique_ptr<Value> Parse(StringPiece input); // Returns the error code. JSONReader::JsonParseError error_code() const; @@ -133,7 +134,7 @@ class BASE_EXPORT JSONParser { size_t length_; // The copied string representation. NULL until Convert() is called. - // Strong. scoped_ptr<T> has too much of an overhead here. + // Strong. std::unique_ptr<T> has too much of an overhead here. std::string* string_; }; diff --git a/third_party/chromium/base/json/json_parser_unittest.cc b/third_party/chromium/base/json/json_parser_unittest.cc index 956e277..a6c360d 100644 --- a/third_party/chromium/base/json/json_parser_unittest.cc +++ b/third_party/chromium/base/json/json_parser_unittest.cc @@ -6,10 +6,11 @@ #include <stddef.h> +#include <memory> + #include <gtest/gtest.h> #include "base/json/json_reader.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" namespace base { @@ -35,7 +36,7 @@ class JSONParserTest : public testing::Test { TEST_F(JSONParserTest, NextChar) { std::string input("Hello world"); - scoped_ptr<JSONParser> parser(NewTestParser(input)); + std::unique_ptr<JSONParser> parser(NewTestParser(input)); EXPECT_EQ('H', *parser->pos_); for (size_t i = 1; i < input.length(); ++i) { @@ -46,8 +47,8 @@ TEST_F(JSONParserTest, NextChar) { TEST_F(JSONParserTest, ConsumeString) { std::string input("\"test\",|"); - scoped_ptr<JSONParser> parser(NewTestParser(input)); - scoped_ptr<Value> value(parser->ConsumeString()); + std::unique_ptr<JSONParser> parser(NewTestParser(input)); + std::unique_ptr<Value> value(parser->ConsumeString()); EXPECT_EQ('"', *parser->pos_); TestLastThree(parser.get()); @@ -60,8 +61,8 @@ TEST_F(JSONParserTest, ConsumeString) { TEST_F(JSONParserTest, ConsumeList) { std::string input("[true, false],|"); - scoped_ptr<JSONParser> parser(NewTestParser(input)); - scoped_ptr<Value> value(parser->ConsumeList()); + std::unique_ptr<JSONParser> parser(NewTestParser(input)); + std::unique_ptr<Value> value(parser->ConsumeList()); EXPECT_EQ(']', *parser->pos_); TestLastThree(parser.get()); @@ -74,8 +75,8 @@ TEST_F(JSONParserTest, ConsumeList) { TEST_F(JSONParserTest, ConsumeDictionary) { std::string input("{\"abc\":\"def\"},|"); - scoped_ptr<JSONParser> parser(NewTestParser(input)); - scoped_ptr<Value> value(parser->ConsumeDictionary()); + std::unique_ptr<JSONParser> parser(NewTestParser(input)); + std::unique_ptr<Value> value(parser->ConsumeDictionary()); EXPECT_EQ('}', *parser->pos_); TestLastThree(parser.get()); @@ -91,8 +92,8 @@ TEST_F(JSONParserTest, ConsumeDictionary) { TEST_F(JSONParserTest, ConsumeLiterals) { // Literal |true|. std::string input("true,|"); - scoped_ptr<JSONParser> parser(NewTestParser(input)); - scoped_ptr<Value> value(parser->ConsumeLiteral()); + std::unique_ptr<JSONParser> parser(NewTestParser(input)); + std::unique_ptr<Value> value(parser->ConsumeLiteral()); EXPECT_EQ('e', *parser->pos_); TestLastThree(parser.get()); @@ -129,8 +130,8 @@ TEST_F(JSONParserTest, ConsumeLiterals) { TEST_F(JSONParserTest, ConsumeNumbers) { // Integer. std::string input("1234,|"); - scoped_ptr<JSONParser> parser(NewTestParser(input)); - scoped_ptr<Value> value(parser->ConsumeNumber()); + std::unique_ptr<JSONParser> parser(NewTestParser(input)); + std::unique_ptr<Value> value(parser->ConsumeNumber()); EXPECT_EQ('4', *parser->pos_); TestLastThree(parser.get()); @@ -206,7 +207,7 @@ TEST_F(JSONParserTest, ErrorMessages) { // Error strings should not be modified in case of success. std::string error_message; int error_code = 0; - scoped_ptr<Value> root = JSONReader::ReadAndReturnError( + std::unique_ptr<Value> root = JSONReader::ReadAndReturnError( "[42]", JSON_PARSE_RFC, &error_code, &error_message); EXPECT_TRUE(error_message.empty()); EXPECT_EQ(0, error_code); @@ -310,7 +311,7 @@ TEST_F(JSONParserTest, Decode4ByteUtf8Char) { "[\"😇\",[],[],[],{\"google:suggesttype\":[]}]"; std::string error_message; int error_code = 0; - scoped_ptr<Value> root = JSONReader::ReadAndReturnError( + std::unique_ptr<Value> root = JSONReader::ReadAndReturnError( kUtf8Data, JSON_PARSE_RFC, &error_code, &error_message); EXPECT_TRUE(root.get()) << error_message; } diff --git a/third_party/chromium/base/json/json_reader.cc b/third_party/chromium/base/json/json_reader.cc index 3ab5f75..4ff7496 100644 --- a/third_party/chromium/base/json/json_reader.cc +++ b/third_party/chromium/base/json/json_reader.cc @@ -43,27 +43,28 @@ JSONReader::~JSONReader() { } // static -scoped_ptr<Value> JSONReader::Read(const StringPiece& json) { +std::unique_ptr<Value> JSONReader::Read(StringPiece json) { internal::JSONParser parser(JSON_PARSE_RFC); - return make_scoped_ptr(parser.Parse(json)); + return parser.Parse(json); } // static -scoped_ptr<Value> JSONReader::Read(const StringPiece& json, int options) { +std::unique_ptr<Value> JSONReader::Read(StringPiece json, int options) { internal::JSONParser parser(options); - return make_scoped_ptr(parser.Parse(json)); + return parser.Parse(json); } // static -scoped_ptr<Value> JSONReader::ReadAndReturnError(const StringPiece& json, - int options, - int* error_code_out, - std::string* error_msg_out, - int* error_line_out, - int* error_column_out) { +std::unique_ptr<Value> JSONReader::ReadAndReturnError( + const StringPiece& json, + int options, + int* error_code_out, + std::string* error_msg_out, + int* error_line_out, + int* error_column_out) { internal::JSONParser parser(options); - scoped_ptr<Value> root(parser.Parse(json)); + std::unique_ptr<Value> root(parser.Parse(json)); if (!root) { if (error_code_out) *error_code_out = parser.error_code(); @@ -105,8 +106,8 @@ std::string JSONReader::ErrorCodeToString(JsonParseError error_code) { } } -scoped_ptr<Value> JSONReader::ReadToValue(const std::string& json) { - return make_scoped_ptr(parser_->Parse(json)); +std::unique_ptr<Value> JSONReader::ReadToValue(StringPiece json) { + return parser_->Parse(json); } JSONReader::JsonParseError JSONReader::error_code() const { diff --git a/third_party/chromium/base/json/json_reader.h b/third_party/chromium/base/json/json_reader.h index c6bcb52..f647724 100644 --- a/third_party/chromium/base/json/json_reader.h +++ b/third_party/chromium/base/json/json_reader.h @@ -28,10 +28,10 @@ #ifndef BASE_JSON_JSON_READER_H_ #define BASE_JSON_JSON_READER_H_ +#include <memory> #include <string> #include "base/base_export.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" namespace base { @@ -93,30 +93,31 @@ class BASE_EXPORT JSONReader { // Reads and parses |json|, returning a Value. The caller owns the returned // instance. If |json| is not a properly formed JSON string, returns NULL. - static scoped_ptr<Value> Read(const StringPiece& json); + static std::unique_ptr<Value> Read(StringPiece json); // Reads and parses |json|, returning a Value owned by the caller. The // parser respects the given |options|. If the input is not properly formed, // returns NULL. - static scoped_ptr<Value> Read(const StringPiece& json, int options); + static std::unique_ptr<Value> Read(StringPiece json, int options); // Reads and parses |json| like Read(). |error_code_out| and |error_msg_out| // are optional. If specified and NULL is returned, they will be populated // an error code and a formatted error message (including error location if // appropriate). Otherwise, they will be unmodified. - static scoped_ptr<Value> ReadAndReturnError(const StringPiece& json, - int options, // JSONParserOptions - int* error_code_out, - std::string* error_msg_out, - int* error_line_out = nullptr, - int* error_column_out = nullptr); + static std::unique_ptr<Value> ReadAndReturnError( + const StringPiece& json, + int options, // JSONParserOptions + int* error_code_out, + std::string* error_msg_out, + int* error_line_out = nullptr, + int* error_column_out = nullptr); // Converts a JSON parse error code into a human readable message. // Returns an empty string if error_code is JSON_NO_ERROR. static std::string ErrorCodeToString(JsonParseError error_code); // Parses an input string into a Value that is owned by the caller. - scoped_ptr<Value> ReadToValue(const std::string& json); + std::unique_ptr<Value> ReadToValue(StringPiece json); // Returns the error code if the last call to ReadToValue() failed. // Returns JSON_NO_ERROR otherwise. @@ -127,7 +128,7 @@ class BASE_EXPORT JSONReader { std::string GetErrorMessage() const; private: - scoped_ptr<internal::JSONParser> parser_; + std::unique_ptr<internal::JSONParser> parser_; }; } // namespace base diff --git a/third_party/chromium/base/json/json_reader_unittest.cc b/third_party/chromium/base/json/json_reader_unittest.cc index 2bfd10e..b1ad46e 100644 --- a/third_party/chromium/base/json/json_reader_unittest.cc +++ b/third_party/chromium/base/json/json_reader_unittest.cc @@ -7,10 +7,10 @@ #include <stddef.h> #include <gtest/gtest.h> +#include <memory> #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" #include "base/strings/utf_string_conversion_utils.h" #include "base/values.h" @@ -20,7 +20,7 @@ namespace base { TEST(JSONReaderTest, Reading) { // some whitespace checking - scoped_ptr<Value> root = JSONReader().ReadToValue(" null "); + std::unique_ptr<Value> root = JSONReader().ReadToValue(" null "); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_NULL)); @@ -249,7 +249,7 @@ TEST(JSONReaderTest, Reading) { EXPECT_EQ(3U, list->GetSize()); // Test with trailing comma. Should be parsed the same as above. - scoped_ptr<Value> root2 = + std::unique_ptr<Value> root2 = JSONReader::Read("[true, false, null, ]", JSON_ALLOW_TRAILING_COMMAS); EXPECT_TRUE(root->Equals(root2.get())); @@ -543,15 +543,15 @@ TEST(JSONReaderTest, Reading) { // Tests that the root of a JSON object can be deleted safely while its // children outlive it. TEST(JSONReaderTest, StringOptimizations) { - scoped_ptr<Value> dict_literal_0; - scoped_ptr<Value> dict_literal_1; - scoped_ptr<Value> dict_string_0; - scoped_ptr<Value> dict_string_1; - scoped_ptr<Value> list_value_0; - scoped_ptr<Value> list_value_1; + std::unique_ptr<Value> dict_literal_0; + std::unique_ptr<Value> dict_literal_1; + std::unique_ptr<Value> dict_string_0; + std::unique_ptr<Value> dict_string_1; + std::unique_ptr<Value> list_value_0; + std::unique_ptr<Value> list_value_1; { - scoped_ptr<Value> root = JSONReader::Read( + std::unique_ptr<Value> root = JSONReader::Read( "{" " \"test\": {" " \"foo\": true," diff --git a/third_party/chromium/base/json/json_writer_unittest.cc b/third_party/chromium/base/json/json_writer_unittest.cc index ca99f4d..7aaa78b 100644 --- a/third_party/chromium/base/json/json_writer_unittest.cc +++ b/third_party/chromium/base/json/json_writer_unittest.cc @@ -6,6 +6,7 @@ #include <gtest/gtest.h> +#include "base/memory/ptr_util.h" #include "base/values.h" #include "build/build_config.h" @@ -57,11 +58,11 @@ TEST(JSONWriterTest, NestedTypes) { // Writer unittests like empty list/dict nesting, // list list nesting, etc. DictionaryValue root_dict; - scoped_ptr<ListValue> list(new ListValue()); - scoped_ptr<DictionaryValue> inner_dict(new DictionaryValue()); + std::unique_ptr<ListValue> list(new ListValue()); + std::unique_ptr<DictionaryValue> inner_dict(new DictionaryValue()); inner_dict->SetInteger("inner int", 10); list->Append(std::move(inner_dict)); - list->Append(make_scoped_ptr(new ListValue())); + list->Append(WrapUnique(new ListValue())); list->AppendBoolean(true); root_dict.Set("list", std::move(list)); @@ -93,7 +94,7 @@ TEST(JSONWriterTest, KeysWithPeriods) { DictionaryValue period_dict; period_dict.SetIntegerWithoutPathExpansion("a.b", 3); period_dict.SetIntegerWithoutPathExpansion("c", 2); - scoped_ptr<DictionaryValue> period_dict2(new DictionaryValue()); + std::unique_ptr<DictionaryValue> period_dict2(new DictionaryValue()); period_dict2->SetIntegerWithoutPathExpansion("g.h.i.j", 1); period_dict.SetWithoutPathExpansion("d.e.f", std::move(period_dict2)); EXPECT_TRUE(JSONWriter::Write(period_dict, &output_js)); @@ -111,7 +112,7 @@ TEST(JSONWriterTest, BinaryValues) { // Binary values should return errors unless suppressed via the // OPTIONS_OMIT_BINARY_VALUES flag. - scoped_ptr<Value> root(BinaryValue::CreateWithCopiedBuffer("asdf", 4)); + std::unique_ptr<Value> root(BinaryValue::CreateWithCopiedBuffer("asdf", 4)); EXPECT_FALSE(JSONWriter::Write(*root, &output_js)); EXPECT_TRUE(JSONWriter::WriteWithOptions( *root, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js)); @@ -119,9 +120,9 @@ TEST(JSONWriterTest, BinaryValues) { ListValue binary_list; binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4)); - binary_list.Append(make_scoped_ptr(new FundamentalValue(5))); + binary_list.Append(WrapUnique(new FundamentalValue(5))); binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4)); - binary_list.Append(make_scoped_ptr(new FundamentalValue(2))); + binary_list.Append(WrapUnique(new FundamentalValue(2))); binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4)); EXPECT_FALSE(JSONWriter::Write(binary_list, &output_js)); EXPECT_TRUE(JSONWriter::WriteWithOptions( @@ -130,13 +131,13 @@ TEST(JSONWriterTest, BinaryValues) { DictionaryValue binary_dict; binary_dict.Set( - "a", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4))); + "a", WrapUnique(BinaryValue::CreateWithCopiedBuffer("asdf", 4))); binary_dict.SetInteger("b", 5); binary_dict.Set( - "c", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4))); + "c", WrapUnique(BinaryValue::CreateWithCopiedBuffer("asdf", 4))); binary_dict.SetInteger("d", 2); binary_dict.Set( - "e", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4))); + "e", WrapUnique(BinaryValue::CreateWithCopiedBuffer("asdf", 4))); EXPECT_FALSE(JSONWriter::Write(binary_dict, &output_js)); EXPECT_TRUE(JSONWriter::WriteWithOptions( binary_dict, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js)); |