• Nate Fischer's avatar
    Variations: add an option to avoid SharedPreferences · 0d7bb6db
    Nate Fischer authored
    No change to logic for Chrome, this only affects WebView. This adds an
    option to VariationsSeedStore to configure it to avoid accessing the
    "first run" Java SharedPreferences. Any access to SharedPreferences may
    perform disk IO; since WebView initializes variations on the UI thread,
    this causes a strictmode violation.
    
    WebView doesn't use the first run prefs, so this adds a configuration
    parameter to completely avoid SharedPreferences. This also adds unit
    tests to verify SharedPreferences are not modified when this parameter
    is passed.
    
    Fixed: 1131941
    Test: out/Default/bin/run_components_unittests -f VariationsSeedStore*
    Test: android_webview/tools/run_cts.py -m CtsWebViewStartupApp.apk
    Test: Locally add 'assert false' next to SharedPreferences access, verify WebView doesn't crash
    Change-Id: I137fcbc49b4619dcde84fa1d0375edf6d421c8eb
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444473
    Auto-Submit: Nate Fischer <ntfschr@chromium.org>
    Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
    Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
    Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
    Reviewed-by: default avatarRichard Coles <torne@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#813944}
    0d7bb6db
variations_seed_store_unittest.cc 55.9 KB