diff options
author | yongsheng.zhu@intel.com <yongsheng.zhu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-23 03:42:38 +0000 |
---|---|---|
committer | yongsheng.zhu@intel.com <yongsheng.zhu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-23 03:42:38 +0000 |
commit | 72059f1c9374518d2894e9efc2f0da7e66438b19 (patch) | |
tree | 48c377accc0dbc49d3cd55bf1a0c7a15e57277f8 /base/json | |
parent | 6f087ad8c60823e0b79005e8cdc84ae8d2b70b27 (diff) | |
download | chromium_src-72059f1c9374518d2894e9efc2f0da7e66438b19.zip chromium_src-72059f1c9374518d2894e9efc2f0da7e66438b19.tar.gz chromium_src-72059f1c9374518d2894e9efc2f0da7e66438b19.tar.bz2 |
Fix the failed case ValueStoreTest.DotsInKeyNamesWithDicts for Android
Json parser uses a stack-based input copy string and the parsed result
'Value' references the internal pointer of the input copy string. To
make the references valid, 'Value' has one member std::string to swap
its content with the input copy string. On other platforms, the member
std::string can get the internal pointer of the input copy string.
However, on Android, std::string just swaps the content of two strings
instead of swapping their internal pointers. This makes the pointer
reference of value invalid.
Fix this by forcing options |= JSON_DETACHABLE_CHILDREN for Android so
disable this optimization.
BUG=139434
TEST=run_tests.py -s unit_tests
Review URL: https://chromiumcodereview.appspot.com/10831322
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152944 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/json')
-rw-r--r-- | base/json/json_parser.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc index 0cb59ee..00a6a63 100644 --- a/base/json/json_parser.cc +++ b/base/json/json_parser.cc @@ -208,7 +208,10 @@ JSONParser::~JSONParser() { Value* JSONParser::Parse(const StringPiece& input) { // TODO(rsesek): Windows has problems with StringPiece/hidden roots. Fix // <http://crbug.com/126107> when my Windows box arrives. -#if defined(OS_WIN) + // For Android, swapping string doesn't mean swapping internal pointers + // but swapping contents. Since it can't provide the performance gain, + // set the below flag to disable the optimization and make it work. +#if defined(OS_WIN) || defined(OS_ANDROID) options_ |= JSON_DETACHABLE_CHILDREN; #endif |