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_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