Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c23ebad authored by Steve Block's avatar Steve Block
Browse files

Update the storage locations used by the Chromium HTTP stack

This updates the strorage locations to better match those used by the
Android HTTP stack.

The corresponding external/webkit change is
https://android-git.corp.google.com/g/70643

Bug: 3039536
Change-Id: Ia7ea68d1472e96788a7fbaa6e8f7aa1ee51b3fb0
parent 1d9fc8c5
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ class BrowserFrame extends Handler {
    // queue has been cleared,they are ignored.
    private boolean mBlockMessages = false;

    private static String sDataDirectory = "";
    private static String sDatabaseDirectory;
    private static String sCacheDirectory;

    // Is this frame the main frame?
    private boolean mIsMainFrame;
@@ -228,9 +229,11 @@ class BrowserFrame extends Handler {
        AssetManager am = context.getAssets();
        nativeCreateFrame(w, am, proxy.getBackForwardList());

        if (sDataDirectory.length() == 0) {
            String dir = appContext.getFilesDir().getAbsolutePath();
            sDataDirectory =  dir.substring(0, dir.lastIndexOf('/'));
        if (sDatabaseDirectory == null) {
            sDatabaseDirectory = appContext.getDatabasePath("dummy").getParent();
        }
        if (sCacheDirectory == null) {
            sCacheDirectory = appContext.getCacheDir().getAbsolutePath();
        }

        if (DebugFlags.BROWSER_FRAME) {
@@ -652,11 +655,19 @@ class BrowserFrame extends Handler {
    }

    /**
     * Called by JNI. Gets the applications data directory
     * @return String The applications data directory
     * Called by JNI. Gets the application's database directory, excluding the trailing slash.
     * @return String The application's database directory
     */
    private static String getDatabaseDirectory() {
        return sDatabaseDirectory;
    }

    /**
     * Called by JNI. Gets the application's cache directory, excluding the trailing slash.
     * @return String The application's cache directory
     */
    private static String getDataDirectory() {
        return sDataDirectory;
    private static String getCacheDirectory() {
        return sCacheDirectory;
    }

    /**
+12 −4
Original line number Diff line number Diff line
@@ -1875,10 +1875,18 @@ public class WebView extends AbsoluteLayout
     * @hide pending API council approval.
     */
    public static boolean cleanupPrivateBrowsingFiles(Context context) {
        return nativeCleanupPrivateBrowsingFiles(context.getFilesDir().getParent());
    }

    private static native boolean nativeCleanupPrivateBrowsingFiles(String dataDirectory);
        // It seems wrong that we have to pass the storage locations here, given
        // that the storage files are created native-side in WebRequestContext
        // (albeit using a dumb getter on BrowserFrame to get the paths from
        // Java). It looks like this is required because we may need to call
        // this method before the BrowserFrame has been set up.
        // TODO: Investigate whether this can be avoided.
        return nativeCleanupPrivateBrowsingFiles(context.getDatabasePath("dummy").getParent(),
                                                 context.getCacheDir().getAbsolutePath());
    }

    private static native boolean nativeCleanupPrivateBrowsingFiles(String databaseDirectory,
                                                                    String cacheDirectory);

    private boolean extendScroll(int y) {
        int finalY = mScroller.getFinalY();
+3 −0
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@ public class WebViewDatabase {
    private final Object mFormLock = new Object();
    private final Object mHttpAuthLock = new Object();

    // TODO: The Chromium HTTP stack handles cookies independently.
    // We should consider removing the cookies table if and when we switch to
    // the Chromium HTTP stack for good.
    private static final String mTableNames[] = {
        "cookies", "password", "formurl", "formdata", "httpauth"
    };