Pull the new r369476 of base library from Chromium

The merge was done against r369476 which corresponds to git commit
0471d0e2e2ef4a544a63481a389e1df33ea7c00a of Jan 14, 2016

Change-Id: Ie6894cf65424cc5ad115110faccd51602b2d1234
Reviewed-on: https://weave-review.googlesource.com/2225
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/third_party/chromium/base/json/json_parser.cc b/third_party/chromium/base/json/json_parser.cc
index 964fcd4..304a7bd 100644
--- a/third_party/chromium/base/json/json_parser.cc
+++ b/third_party/chromium/base/json/json_parser.cc
@@ -7,6 +7,7 @@
 #include <cmath>
 
 #include "base/logging.h"
+#include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
@@ -23,14 +24,14 @@
 
 const int kStackMaxDepth = 100;
 
-const int32 kExtendedASCIIStart = 0x80;
+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.
-class DictionaryHiddenRootValue : public base::DictionaryValue {
+class DictionaryHiddenRootValue : public DictionaryValue {
  public:
   DictionaryHiddenRootValue(std::string* json, Value* root) : json_(json) {
     DCHECK(root->IsType(Value::TYPE_DICTIONARY));
@@ -42,7 +43,7 @@
 
     // First deep copy to convert JSONStringValue to std::string and swap that
     // copy with |other|, which contains the new contents of |this|.
-    scoped_ptr<base::DictionaryValue> copy(DeepCopy());
+    scoped_ptr<DictionaryValue> copy(DeepCopy());
     copy->Swap(other);
 
     // Then erase the contents of the current dictionary and swap in the
@@ -80,7 +81,7 @@
   DISALLOW_COPY_AND_ASSIGN(DictionaryHiddenRootValue);
 };
 
-class ListHiddenRootValue : public base::ListValue {
+class ListHiddenRootValue : public ListValue {
  public:
   ListHiddenRootValue(std::string* json, Value* root) : json_(json) {
     DCHECK(root->IsType(Value::TYPE_LIST));
@@ -92,7 +93,7 @@
 
     // First deep copy to convert JSONStringValue to std::string and swap that
     // copy with |other|, which contains the new contents of |this|.
-    scoped_ptr<base::ListValue> copy(DeepCopy());
+    scoped_ptr<ListValue> copy(DeepCopy());
     copy->Swap(other);
 
     // Then erase the contents of the current list and swap in the new contents,
@@ -129,14 +130,14 @@
 // A variant on StringValue that uses StringPiece instead of copying the string
 // into the Value. This can only be stored in a child of hidden root (above),
 // otherwise the referenced string will not be guaranteed to outlive it.
-class JSONStringValue : public base::Value {
+class JSONStringValue : public Value {
  public:
-  explicit JSONStringValue(const base::StringPiece& piece)
+  explicit JSONStringValue(const StringPiece& piece)
       : Value(TYPE_STRING),
         string_piece_(piece) {
   }
 
-  // Overridden from base::Value:
+  // Overridden from Value:
   bool GetAsString(std::string* out_value) const override {
     string_piece_.CopyToString(out_value);
     return true;
@@ -152,7 +153,7 @@
 
  private:
   // The location in the original input stream.
-  base::StringPiece string_piece_;
+  StringPiece string_piece_;
 
   DISALLOW_COPY_AND_ASSIGN(JSONStringValue);
 };
@@ -222,9 +223,9 @@
   // <0xEF 0xBB 0xBF>, advance the start position to avoid the
   // ParseNextToken function mis-treating a Unicode BOM as an invalid
   // character and returning NULL.
-  if (CanConsume(3) && static_cast<uint8>(*pos_) == 0xEF &&
-      static_cast<uint8>(*(pos_ + 1)) == 0xBB &&
-      static_cast<uint8>(*(pos_ + 2)) == 0xBF) {
+  if (CanConsume(3) && static_cast<uint8_t>(*pos_) == 0xEF &&
+      static_cast<uint8_t>(*(pos_ + 1)) == 0xBB &&
+      static_cast<uint8_t>(*(pos_ + 2)) == 0xBF) {
     NextNChars(3);
   }
 
@@ -269,6 +270,14 @@
       JSONReader::ErrorCodeToString(error_code_));
 }
 
+int JSONParser::error_line() const {
+  return error_line_;
+}
+
+int JSONParser::error_column() const {
+  return error_column_;
+}
+
 // StringBuilder ///////////////////////////////////////////////////////////////
 
 JSONParser::StringBuilder::StringBuilder()
@@ -608,7 +617,7 @@
   StringBuilder string(NextChar());
 
   int length = end_pos_ - start_pos_;
-  int32 next_char = 0;
+  int32_t next_char = 0;
 
   while (CanConsume(1)) {
     pos_ = start_pos_ + index_;  // CBU8_NEXT is postcrement.
@@ -769,13 +778,19 @@
       return false;
     }
 
-    uint32 code_point = CBU16_GET_SUPPLEMENTARY(code_unit16_high,
-                                                code_unit16_low);
+    uint32_t code_point =
+        CBU16_GET_SUPPLEMENTARY(code_unit16_high, code_unit16_low);
+    if (!IsValidCharacter(code_point))
+      return false;
+
     offset = 0;
     CBU8_APPEND_UNSAFE(code_unit8, offset, code_point);
   } else {
     // Not a surrogate.
     DCHECK(CBU16_IS_SINGLE(code_unit16_high));
+    if (!IsValidCharacter(code_unit16_high))
+      return false;
+
     CBU8_APPEND_UNSAFE(code_unit8, offset, code_unit16_high);
   }
 
@@ -783,9 +798,11 @@
   return true;
 }
 
-void JSONParser::DecodeUTF8(const int32& point, StringBuilder* dest) {
+void JSONParser::DecodeUTF8(const int32_t& point, StringBuilder* dest) {
+  DCHECK(IsValidCharacter(point));
+
   // Anything outside of the basic ASCII plane will need to be decoded from
-  // int32 to a multi-byte sequence.
+  // int32_t to a multi-byte sequence.
   if (point < kExtendedASCIIStart) {
     dest->Append(static_cast<char>(point));
   } else {
@@ -867,7 +884,7 @@
     return new FundamentalValue(num_int);
 
   double num_double;
-  if (base::StringToDouble(num_string.as_string(), &num_double) &&
+  if (StringToDouble(num_string.as_string(), &num_double) &&
       std::isfinite(num_double)) {
     return new FundamentalValue(num_double);
   }
diff --git a/third_party/chromium/base/json/json_parser.h b/third_party/chromium/base/json/json_parser.h
index c8ed0cd..fc04594 100644
--- a/third_party/chromium/base/json/json_parser.h
+++ b/third_party/chromium/base/json/json_parser.h
@@ -5,20 +5,22 @@
 #ifndef BASE_JSON_JSON_PARSER_H_
 #define BASE_JSON_JSON_PARSER_H_
 
+#include <stddef.h>
+#include <stdint.h>
+
 #include <string>
 
 #include "base/base_export.h"
-#include "base/basictypes.h"
 #include "base/compiler_specific.h"
 #include "base/gtest_prod_util.h"
 #include "base/json/json_reader.h"
+#include "base/macros.h"
 #include "base/strings/string_piece.h"
 
 namespace base {
-class Value;
-}
 
-namespace base {
+class Value;
+
 namespace internal {
 
 class JSONParserTest;
@@ -41,7 +43,7 @@
 // of a token, such that the next iteration of the parser will be at the byte
 // immediately following the token, which would likely be the first byte of the
 // next token.
-class BASE_EXPORT_PRIVATE JSONParser {
+class BASE_EXPORT JSONParser {
  public:
   explicit JSONParser(int options);
   ~JSONParser();
@@ -56,6 +58,14 @@
   // Returns the human-friendly error message.
   std::string GetErrorMessage() const;
 
+  // Returns the error line number if parse error happened. Otherwise always
+  // returns 0.
+  int error_line() const;
+
+  // Returns the error column number if parse error happened. Otherwise always
+  // returns 0.
+  int error_column() const;
+
  private:
   enum Token {
     T_OBJECT_BEGIN,           // {
@@ -181,7 +191,7 @@
   // Helper function for ConsumeStringRaw() that takes a single code point,
   // decodes it into UTF-8 units, and appends it to the given builder. The
   // point must be valid.
-  void DecodeUTF8(const int32& point, StringBuilder* dest);
+  void DecodeUTF8(const int32_t& point, StringBuilder* dest);
 
   // Assuming that the parser is wound to the start of a valid JSON number,
   // this parses and converts it to either an int or double value.
diff --git a/third_party/chromium/base/json/json_parser_unittest.cc b/third_party/chromium/base/json/json_parser_unittest.cc
index c432eee..956e277 100644
--- a/third_party/chromium/base/json/json_parser_unittest.cc
+++ b/third_party/chromium/base/json/json_parser_unittest.cc
@@ -4,6 +4,8 @@
 
 #include "base/json/json_parser.h"
 
+#include <stddef.h>
+
 #include <gtest/gtest.h>
 
 #include "base/json/json_reader.h"
@@ -204,17 +206,16 @@
   // Error strings should not be modified in case of success.
   std::string error_message;
   int error_code = 0;
-  scoped_ptr<Value> root;
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "[42]", JSON_PARSE_RFC, &error_code, &error_message));
+  scoped_ptr<Value> root = JSONReader::ReadAndReturnError(
+      "[42]", JSON_PARSE_RFC, &error_code, &error_message);
   EXPECT_TRUE(error_message.empty());
   EXPECT_EQ(0, error_code);
 
   // Test line and column counting
   const char big_json[] = "[\n0,\n1,\n2,\n3,4,5,6 7,\n8,\n9\n]";
   // error here ----------------------------------^
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      big_json, JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError(big_json, JSON_PARSE_RFC, &error_code,
+                                        &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(5, 10, JSONReader::kSyntaxError),
             error_message);
@@ -226,16 +227,16 @@
   const char big_json_crlf[] =
       "[\r\n0,\r\n1,\r\n2,\r\n3,4,5,6 7,\r\n8,\r\n9\r\n]";
   // error here ----------------------^
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      big_json_crlf, JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError(big_json_crlf, JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(5, 10, JSONReader::kSyntaxError),
             error_message);
   EXPECT_EQ(JSONReader::JSON_SYNTAX_ERROR, error_code);
 
   // Test each of the error conditions
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "{},{}", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("{},{}", JSON_PARSE_RFC, &error_code,
+                                        &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 3,
       JSONReader::kUnexpectedDataAfterRoot), error_message);
@@ -246,56 +247,56 @@
     nested_json.insert(nested_json.begin(), '[');
     nested_json.append(1, ']');
   }
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      nested_json, JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError(nested_json, JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 100, JSONReader::kTooMuchNesting),
             error_message);
   EXPECT_EQ(JSONReader::JSON_TOO_MUCH_NESTING, error_code);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "[1,]", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("[1,]", JSON_PARSE_RFC, &error_code,
+                                        &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 4, JSONReader::kTrailingComma),
             error_message);
   EXPECT_EQ(JSONReader::JSON_TRAILING_COMMA, error_code);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "{foo:\"bar\"}", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("{foo:\"bar\"}", JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 2,
       JSONReader::kUnquotedDictionaryKey), error_message);
   EXPECT_EQ(JSONReader::JSON_UNQUOTED_DICTIONARY_KEY, error_code);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "{\"foo\":\"bar\",}", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("{\"foo\":\"bar\",}", JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 14, JSONReader::kTrailingComma),
             error_message);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "[nu]", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("[nu]", JSON_PARSE_RFC, &error_code,
+                                        &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 2, JSONReader::kSyntaxError),
             error_message);
   EXPECT_EQ(JSONReader::JSON_SYNTAX_ERROR, error_code);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "[\"xxx\\xq\"]", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("[\"xxx\\xq\"]", JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape),
             error_message);
   EXPECT_EQ(JSONReader::JSON_INVALID_ESCAPE, error_code);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "[\"xxx\\uq\"]", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("[\"xxx\\uq\"]", JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape),
             error_message);
   EXPECT_EQ(JSONReader::JSON_INVALID_ESCAPE, error_code);
 
-  root.reset(JSONReader::DeprecatedReadAndReturnError(
-      "[\"xxx\\q\"]", JSON_PARSE_RFC, &error_code, &error_message));
+  root = JSONReader::ReadAndReturnError("[\"xxx\\q\"]", JSON_PARSE_RFC,
+                                        &error_code, &error_message);
   EXPECT_FALSE(root.get());
   EXPECT_EQ(JSONParser::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape),
             error_message);
@@ -309,10 +310,18 @@
       "[\"😇\",[],[],[],{\"google:suggesttype\":[]}]";
   std::string error_message;
   int error_code = 0;
-  scoped_ptr<Value> root(JSONReader::DeprecatedReadAndReturnError(
-      kUtf8Data, JSON_PARSE_RFC, &error_code, &error_message));
+  scoped_ptr<Value> root = JSONReader::ReadAndReturnError(
+      kUtf8Data, JSON_PARSE_RFC, &error_code, &error_message);
   EXPECT_TRUE(root.get()) << error_message;
 }
 
+TEST_F(JSONParserTest, DecodeUnicodeNonCharacter) {
+  // Tests Unicode code points (encoded as escaped UTF-16) that are not valid
+  // characters.
+  EXPECT_FALSE(JSONReader::Read("[\"\\ufdd0\"]"));
+  EXPECT_FALSE(JSONReader::Read("[\"\\ufffe\"]"));
+  EXPECT_FALSE(JSONReader::Read("[\"\\ud83f\\udffe\"]"));
+}
+
 }  // namespace internal
 }  // namespace base
diff --git a/third_party/chromium/base/json/json_reader.cc b/third_party/chromium/base/json/json_reader.cc
index edff8dc..3ab5f75 100644
--- a/third_party/chromium/base/json/json_reader.cc
+++ b/third_party/chromium/base/json/json_reader.cc
@@ -11,8 +11,8 @@
 namespace base {
 
 // Values 1000 and above are used by JSONFileValueSerializer::JsonFileError.
-COMPILE_ASSERT(JSONReader::JSON_PARSE_ERROR_COUNT < 1000,
-               json_reader_error_out_of_bounds);
+static_assert(JSONReader::JSON_PARSE_ERROR_COUNT < 1000,
+              "JSONReader error out of bounds");
 
 const char JSONReader::kInvalidEscape[] =
     "Invalid escape sequence.";
@@ -43,41 +43,25 @@
 }
 
 // static
-Value* JSONReader::DeprecatedRead(const std::string& json) {
-  return Read(json).release();
-}
-
-// static
-scoped_ptr<Value> JSONReader::Read(const std::string& json) {
+scoped_ptr<Value> JSONReader::Read(const StringPiece& json) {
   internal::JSONParser parser(JSON_PARSE_RFC);
   return make_scoped_ptr(parser.Parse(json));
 }
 
 // static
-Value* JSONReader::DeprecatedRead(const std::string& json, int options) {
-  return Read(json, options).release();
-}
-
-// static
-scoped_ptr<Value> JSONReader::Read(const std::string& json, int options) {
+scoped_ptr<Value> JSONReader::Read(const StringPiece& json, int options) {
   internal::JSONParser parser(options);
   return make_scoped_ptr(parser.Parse(json));
 }
 
-// static
-Value* JSONReader::DeprecatedReadAndReturnError(const std::string& json,
-                                                int options,
-                                                int* error_code_out,
-                                                std::string* error_msg_out) {
-  return ReadAndReturnError(json, options, error_code_out, error_msg_out)
-      .release();
-}
 
 // static
-scoped_ptr<Value> JSONReader::ReadAndReturnError(const std::string& json,
+scoped_ptr<Value> JSONReader::ReadAndReturnError(const StringPiece& json,
                                                  int options,
                                                  int* error_code_out,
-                                                 std::string* error_msg_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));
   if (!root) {
@@ -85,6 +69,10 @@
       *error_code_out = parser.error_code();
     if (error_msg_out)
       *error_msg_out = parser.GetErrorMessage();
+    if (error_line_out)
+      *error_line_out = parser.error_line();
+    if (error_column_out)
+      *error_column_out = parser.error_column();
   }
 
   return root;
diff --git a/third_party/chromium/base/json/json_reader.h b/third_party/chromium/base/json/json_reader.h
index e177ab8..c6bcb52 100644
--- a/third_party/chromium/base/json/json_reader.h
+++ b/third_party/chromium/base/json/json_reader.h
@@ -31,8 +31,8 @@
 #include <string>
 
 #include "base/base_export.h"
-#include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
+#include "base/strings/string_piece.h"
 
 namespace base {
 
@@ -93,30 +93,23 @@
 
   // 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 std::string& json);
-  // TODO(estade): remove this bare pointer version.
-  static Value* DeprecatedRead(const std::string& json);
+  static scoped_ptr<Value> Read(const 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 std::string& json, int options);
-  // TODO(estade): remove this bare pointer version.
-  static Value* DeprecatedRead(const std::string& json, int options);
+  static scoped_ptr<Value> Read(const 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 std::string& json,
+  static scoped_ptr<Value> ReadAndReturnError(const StringPiece& json,
                                               int options,  // JSONParserOptions
                                               int* error_code_out,
-                                              std::string* error_msg_out);
-  // TODO(estade): remove this bare pointer version.
-  static Value* DeprecatedReadAndReturnError(const std::string& json,
-                                             int options,  // JSONParserOptions
-                                             int* error_code_out,
-                                             std::string* error_msg_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.
diff --git a/third_party/chromium/base/json/json_reader_unittest.cc b/third_party/chromium/base/json/json_reader_unittest.cc
index 35becef..2bfd10e 100644
--- a/third_party/chromium/base/json/json_reader_unittest.cc
+++ b/third_party/chromium/base/json/json_reader_unittest.cc
@@ -4,9 +4,12 @@
 
 #include "base/json/json_reader.h"
 
+#include <stddef.h>
+
 #include <gtest/gtest.h>
 
 #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"
@@ -17,8 +20,7 @@
 
 TEST(JSONReaderTest, Reading) {
   // some whitespace checking
-  scoped_ptr<Value> root;
-  root = JSONReader().ReadToValue("   null   ");
+  scoped_ptr<Value> root = JSONReader().ReadToValue("   null   ");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_NULL));
 
@@ -240,61 +242,56 @@
   EXPECT_FALSE(root.get());
 
   // Basic array
-  root.reset(JSONReader::DeprecatedRead("[true, false, null]"));
+  root = JSONReader::Read("[true, false, null]");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_LIST));
   list = static_cast<ListValue*>(root.get());
   EXPECT_EQ(3U, list->GetSize());
 
   // Test with trailing comma.  Should be parsed the same as above.
-  scoped_ptr<Value> root2;
-  root2.reset(JSONReader::DeprecatedRead("[true, false, null, ]",
-                                         JSON_ALLOW_TRAILING_COMMAS));
+  scoped_ptr<Value> root2 =
+      JSONReader::Read("[true, false, null, ]", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_TRUE(root->Equals(root2.get()));
 
   // Empty array
-  root.reset(JSONReader::DeprecatedRead("[]"));
+  root = JSONReader::Read("[]");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_LIST));
   list = static_cast<ListValue*>(root.get());
   EXPECT_EQ(0U, list->GetSize());
 
   // Nested arrays
-  root.reset(
-      JSONReader::DeprecatedRead("[[true], [], [false, [], [null]], null]"));
+  root = JSONReader::Read("[[true], [], [false, [], [null]], null]");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_LIST));
   list = static_cast<ListValue*>(root.get());
   EXPECT_EQ(4U, list->GetSize());
 
   // Lots of trailing commas.
-  root2.reset(JSONReader::DeprecatedRead(
-      "[[true], [], [false, [], [null, ]  , ], null,]",
-      JSON_ALLOW_TRAILING_COMMAS));
+  root2 = JSONReader::Read("[[true], [], [false, [], [null, ]  , ], null,]",
+                           JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_TRUE(root->Equals(root2.get()));
 
   // Invalid, missing close brace.
-  root.reset(
-      JSONReader::DeprecatedRead("[[true], [], [false, [], [null]], null"));
+  root = JSONReader::Read("[[true], [], [false, [], [null]], null");
   EXPECT_FALSE(root.get());
 
   // Invalid, too many commas
-  root.reset(JSONReader::DeprecatedRead("[true,, null]"));
+  root = JSONReader::Read("[true,, null]");
   EXPECT_FALSE(root.get());
-  root.reset(
-      JSONReader::DeprecatedRead("[true,, null]", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("[true,, null]", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
 
   // Invalid, no commas
-  root.reset(JSONReader::DeprecatedRead("[true null]"));
+  root = JSONReader::Read("[true null]");
   EXPECT_FALSE(root.get());
 
   // Invalid, trailing comma
-  root.reset(JSONReader::DeprecatedRead("[true,]"));
+  root = JSONReader::Read("[true,]");
   EXPECT_FALSE(root.get());
 
   // Valid if we set |allow_trailing_comma| to true.
-  root.reset(JSONReader::DeprecatedRead("[true,]", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("[true,]", JSON_ALLOW_TRAILING_COMMAS);
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_LIST));
   list = static_cast<ListValue*>(root.get());
@@ -308,25 +305,22 @@
 
   // Don't allow empty elements, even if |allow_trailing_comma| is
   // true.
-  root.reset(JSONReader::DeprecatedRead("[,]", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("[,]", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
-  root.reset(
-      JSONReader::DeprecatedRead("[true,,]", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("[true,,]", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
-  root.reset(
-      JSONReader::DeprecatedRead("[,true,]", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("[,true,]", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
-  root.reset(
-      JSONReader::DeprecatedRead("[true,,false]", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("[true,,false]", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
 
   // Test objects
-  root.reset(JSONReader::DeprecatedRead("{}"));
+  root = JSONReader::Read("{}");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
 
-  root.reset(JSONReader::DeprecatedRead(
-      "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\" }"));
+  root = JSONReader::Read(
+      "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\" }");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
   DictionaryValue* dict_val = static_cast<DictionaryValue*>(root.get());
@@ -340,36 +334,36 @@
   EXPECT_TRUE(dict_val->GetString("S", &str_val));
   EXPECT_EQ("str", str_val);
 
-  root2.reset(JSONReader::DeprecatedRead(
+  root2 = JSONReader::Read(
       "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\", }",
-      JSON_ALLOW_TRAILING_COMMAS));
+      JSON_ALLOW_TRAILING_COMMAS);
   ASSERT_TRUE(root2.get());
   EXPECT_TRUE(root->Equals(root2.get()));
 
   // Test newline equivalence.
-  root2.reset(JSONReader::DeprecatedRead(
+  root2 = JSONReader::Read(
       "{\n"
       "  \"number\":9.87654321,\n"
       "  \"null\":null,\n"
       "  \"\\x53\":\"str\",\n"
       "}\n",
-      JSON_ALLOW_TRAILING_COMMAS));
+      JSON_ALLOW_TRAILING_COMMAS);
   ASSERT_TRUE(root2.get());
   EXPECT_TRUE(root->Equals(root2.get()));
 
-  root2.reset(JSONReader::DeprecatedRead(
+  root2 = JSONReader::Read(
       "{\r\n"
       "  \"number\":9.87654321,\r\n"
       "  \"null\":null,\r\n"
       "  \"\\x53\":\"str\",\r\n"
       "}\r\n",
-      JSON_ALLOW_TRAILING_COMMAS));
+      JSON_ALLOW_TRAILING_COMMAS);
   ASSERT_TRUE(root2.get());
   EXPECT_TRUE(root->Equals(root2.get()));
 
   // Test nesting
-  root.reset(JSONReader::DeprecatedRead(
-      "{\"inner\":{\"array\":[true]},\"false\":false,\"d\":{}}"));
+  root = JSONReader::Read(
+      "{\"inner\":{\"array\":[true]},\"false\":false,\"d\":{}}");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
   dict_val = static_cast<DictionaryValue*>(root.get());
@@ -384,14 +378,13 @@
   inner_dict = NULL;
   EXPECT_TRUE(dict_val->GetDictionary("d", &inner_dict));
 
-  root2.reset(JSONReader::DeprecatedRead(
+  root2 = JSONReader::Read(
       "{\"inner\": {\"array\":[true] , },\"false\":false,\"d\":{},}",
-      JSON_ALLOW_TRAILING_COMMAS));
+      JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_TRUE(root->Equals(root2.get()));
 
   // Test keys with periods
-  root.reset(JSONReader::DeprecatedRead(
-      "{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}"));
+  root = JSONReader::Read("{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
   dict_val = static_cast<DictionaryValue*>(root.get());
@@ -408,7 +401,7 @@
                                                          &integer_value));
   EXPECT_EQ(1, integer_value);
 
-  root.reset(JSONReader::DeprecatedRead("{\"a\":{\"b\":2},\"a.b\":1}"));
+  root = JSONReader::Read("{\"a\":{\"b\":2},\"a.b\":1}");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
   dict_val = static_cast<DictionaryValue*>(root.get());
@@ -418,47 +411,45 @@
   EXPECT_EQ(1, integer_value);
 
   // Invalid, no closing brace
-  root.reset(JSONReader::DeprecatedRead("{\"a\": true"));
+  root = JSONReader::Read("{\"a\": true");
   EXPECT_FALSE(root.get());
 
   // Invalid, keys must be quoted
-  root.reset(JSONReader::DeprecatedRead("{foo:true}"));
+  root = JSONReader::Read("{foo:true}");
   EXPECT_FALSE(root.get());
 
   // Invalid, trailing comma
-  root.reset(JSONReader::DeprecatedRead("{\"a\":true,}"));
+  root = JSONReader::Read("{\"a\":true,}");
   EXPECT_FALSE(root.get());
 
   // Invalid, too many commas
-  root.reset(JSONReader::DeprecatedRead("{\"a\":true,,\"b\":false}"));
+  root = JSONReader::Read("{\"a\":true,,\"b\":false}");
   EXPECT_FALSE(root.get());
-  root.reset(JSONReader::DeprecatedRead("{\"a\":true,,\"b\":false}",
-                                        JSON_ALLOW_TRAILING_COMMAS));
+  root =
+      JSONReader::Read("{\"a\":true,,\"b\":false}", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
 
   // Invalid, no separator
-  root.reset(JSONReader::DeprecatedRead("{\"a\" \"b\"}"));
+  root = JSONReader::Read("{\"a\" \"b\"}");
   EXPECT_FALSE(root.get());
 
   // Invalid, lone comma.
-  root.reset(JSONReader::DeprecatedRead("{,}"));
+  root = JSONReader::Read("{,}");
   EXPECT_FALSE(root.get());
-  root.reset(JSONReader::DeprecatedRead("{,}", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("{,}", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
-  root.reset(
-      JSONReader::DeprecatedRead("{\"a\":true,,}", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("{\"a\":true,,}", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
-  root.reset(
-      JSONReader::DeprecatedRead("{,\"a\":true}", JSON_ALLOW_TRAILING_COMMAS));
+  root = JSONReader::Read("{,\"a\":true}", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
-  root.reset(JSONReader::DeprecatedRead("{\"a\":true,,\"b\":false}",
-                                        JSON_ALLOW_TRAILING_COMMAS));
+  root =
+      JSONReader::Read("{\"a\":true,,\"b\":false}", JSON_ALLOW_TRAILING_COMMAS);
   EXPECT_FALSE(root.get());
 
   // Test stack overflow
   std::string evil(1000000, '[');
   evil.append(std::string(1000000, ']'));
-  root.reset(JSONReader::DeprecatedRead(evil));
+  root = JSONReader::Read(evil);
   EXPECT_FALSE(root.get());
 
   // A few thousand adjacent lists is fine.
@@ -468,7 +459,7 @@
     not_evil.append("[],");
   }
   not_evil.append("[]]");
-  root.reset(JSONReader::DeprecatedRead(not_evil));
+  root = JSONReader::Read(not_evil);
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->IsType(Value::TYPE_LIST));
   list = static_cast<ListValue*>(root.get());
@@ -530,20 +521,20 @@
   }
 
   // Test literal root objects.
-  root.reset(JSONReader::DeprecatedRead("null"));
+  root = JSONReader::Read("null");
   EXPECT_TRUE(root->IsType(Value::TYPE_NULL));
 
-  root.reset(JSONReader::DeprecatedRead("true"));
+  root = JSONReader::Read("true");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->GetAsBoolean(&bool_value));
   EXPECT_TRUE(bool_value);
 
-  root.reset(JSONReader::DeprecatedRead("10"));
+  root = JSONReader::Read("10");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->GetAsInteger(&integer_value));
   EXPECT_EQ(10, integer_value);
 
-  root.reset(JSONReader::DeprecatedRead("\"root\""));
+  root = JSONReader::Read("\"root\"");
   ASSERT_TRUE(root.get());
   EXPECT_TRUE(root->GetAsString(&str_val));
   EXPECT_EQ("root", str_val);
diff --git a/third_party/chromium/base/json/json_writer.cc b/third_party/chromium/base/json/json_writer.cc
index 8bf4c6f..be19c93 100644
--- a/third_party/chromium/base/json/json_writer.cc
+++ b/third_party/chromium/base/json/json_writer.cc
@@ -4,13 +4,17 @@
 
 #include "base/json/json_writer.h"
 
+#include <stdint.h>
+
 #include <cmath>
+#include <limits>
 
 #include "base/json/string_escape.h"
 #include "base/logging.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversion_utils.h"
 #include "base/values.h"
+#include "build/build_config.h"
 
 namespace base {
 
@@ -79,10 +83,10 @@
       bool result = node.GetAsDouble(&value);
       DCHECK(result);
       if (omit_double_type_preservation_ &&
-          value <= kint64max &&
-          value >= kint64min &&
+          value <= std::numeric_limits<int64_t>::max() &&
+          value >= std::numeric_limits<int64_t>::min() &&
           std::floor(value) == value) {
-        json_string_->append(Int64ToString(static_cast<int64>(value)));
+        json_string_->append(Int64ToString(static_cast<int64_t>(value)));
         return result;
       }
       std::string real = DoubleToString(value);
diff --git a/third_party/chromium/base/json/json_writer.h b/third_party/chromium/base/json/json_writer.h
index 5711665..ef43341 100644
--- a/third_party/chromium/base/json/json_writer.h
+++ b/third_party/chromium/base/json/json_writer.h
@@ -5,10 +5,12 @@
 #ifndef BASE_JSON_JSON_WRITER_H_
 #define BASE_JSON_JSON_WRITER_H_
 
+#include <stddef.h>
+
 #include <string>
 
 #include "base/base_export.h"
-#include "base/basictypes.h"
+#include "base/macros.h"
 
 namespace base {
 
diff --git a/third_party/chromium/base/json/json_writer_unittest.cc b/third_party/chromium/base/json/json_writer_unittest.cc
index cb88cde..ca99f4d 100644
--- a/third_party/chromium/base/json/json_writer_unittest.cc
+++ b/third_party/chromium/base/json/json_writer_unittest.cc
@@ -7,6 +7,7 @@
 #include <gtest/gtest.h>
 
 #include "base/values.h"
+#include "build/build_config.h"
 
 namespace base {
 
@@ -59,10 +60,10 @@
   scoped_ptr<ListValue> list(new ListValue());
   scoped_ptr<DictionaryValue> inner_dict(new DictionaryValue());
   inner_dict->SetInteger("inner int", 10);
-  list->Append(inner_dict.Pass());
+  list->Append(std::move(inner_dict));
   list->Append(make_scoped_ptr(new ListValue()));
   list->AppendBoolean(true);
-  root_dict.Set("list", list.Pass());
+  root_dict.Set("list", std::move(list));
 
   // Test the pretty-printer.
   EXPECT_TRUE(JSONWriter::Write(root_dict, &output_js));
@@ -94,7 +95,7 @@
   period_dict.SetIntegerWithoutPathExpansion("c", 2);
   scoped_ptr<DictionaryValue> period_dict2(new DictionaryValue());
   period_dict2->SetIntegerWithoutPathExpansion("g.h.i.j", 1);
-  period_dict.SetWithoutPathExpansion("d.e.f", period_dict2.Pass());
+  period_dict.SetWithoutPathExpansion("d.e.f", std::move(period_dict2));
   EXPECT_TRUE(JSONWriter::Write(period_dict, &output_js));
   EXPECT_EQ("{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}", output_js);
 
diff --git a/third_party/chromium/base/json/string_escape.cc b/third_party/chromium/base/json/string_escape.cc
index 7ba612f..a5a38df 100644
--- a/third_party/chromium/base/json/string_escape.cc
+++ b/third_party/chromium/base/json/string_escape.cc
@@ -4,6 +4,10 @@
 
 #include "base/json/string_escape.h"
 
+#include <stddef.h>
+#include <stdint.h>
+
+#include <limits>
 #include <string>
 
 #include "base/logging.h"
@@ -20,15 +24,15 @@
 const char kU16EscapeFormat[] = "\\u%04X";
 
 // The code point to output for an invalid input code unit.
-const uint32 kReplacementCodePoint = 0xFFFD;
+const uint32_t kReplacementCodePoint = 0xFFFD;
 
 // Used below in EscapeSpecialCodePoint().
-COMPILE_ASSERT('<' == 0x3C, less_than_sign_is_0x3c);
+static_assert('<' == 0x3C, "less than sign must be 0x3c");
 
 // Try to escape the |code_point| if it is a known special character. If
 // successful, returns true and appends the escape sequence to |dest|. This
 // isn't required by the spec, but it's more readable by humans.
-bool EscapeSpecialCodePoint(uint32 code_point, std::string* dest) {
+bool EscapeSpecialCodePoint(uint32_t code_point, std::string* dest) {
   // WARNING: if you add a new case here, you need to update the reader as well.
   // Note: \v is in the reader, but not here since the JSON spec doesn't
   // allow it.
@@ -59,6 +63,14 @@
     case '<':
       dest->append("\\u003C");
       break;
+    // Escape the "Line Separator" and "Paragraph Separator" characters, since
+    // they should be treated like a new line \r or \n.
+    case 0x2028:
+      dest->append("\\u2028");
+      break;
+    case 0x2029:
+      dest->append("\\u2029");
+      break;
     default:
       return false;
   }
@@ -72,12 +84,13 @@
   if (put_in_quotes)
     dest->push_back('"');
 
-  // Casting is necessary because ICU uses int32. Try and do so safely.
-  CHECK_LE(str.length(), static_cast<size_t>(kint32max));
-  const int32 length = static_cast<int32>(str.length());
+  // Casting is necessary because ICU uses int32_t. Try and do so safely.
+  CHECK_LE(str.length(),
+           static_cast<size_t>(std::numeric_limits<int32_t>::max()));
+  const int32_t length = static_cast<int32_t>(str.length());
 
-  for (int32 i = 0; i < length; ++i) {
-    uint32 code_point;
+  for (int32_t i = 0; i < length; ++i) {
+    uint32_t code_point;
     if (!ReadUnicodeCharacter(str.data(), length, &i, &code_point)) {
       code_point = kReplacementCodePoint;
       did_replacement = true;
diff --git a/third_party/chromium/base/json/string_escape_unittest.cc b/third_party/chromium/base/json/string_escape_unittest.cc
index 615acc4..586c1e7 100644
--- a/third_party/chromium/base/json/string_escape_unittest.cc
+++ b/third_party/chromium/base/json/string_escape_unittest.cc
@@ -5,7 +5,9 @@
 #include "base/json/string_escape.h"
 
 #include <gtest/gtest.h>
+#include <stddef.h>
 
+#include "base/macros.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversion_utils.h"
 
@@ -22,6 +24,8 @@
     {"b\x0f\x7f\xf0\xff!",  // \xf0\xff is not a valid UTF-8 unit.
         "b\\u000F\x7F\xEF\xBF\xBD\xEF\xBF\xBD!"},
     {"c<>d", "c\\u003C>d"},
+    {"Hello\xe2\x80\xa8world", "Hello\\u2028world"},
+    {"\xe2\x80\xa9purple", "\\u2029purple"},
   };
 
   for (size_t i = 0; i < arraysize(cases); ++i) {