Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert of Pre-cache downloads directory path in PathUtils. (patchset #1
Browse files Browse the repository at this point in the history
… id:1 of https://codereview.chromium.org/1281273003/ )

Reason for revert:
Revert because it breaks new beta. See
https://code.google.com/p/chromium/issues/detail?id=528377

Original issue's description:
> Pre-cache downloads directory path in PathUtils.
>
> When Chrome tabs are swiped away and user starts Chrome again,
> their default downloads directory is requested. This causes a
> StrictMode policy violation since it results in a ~60ms disk
> read. Thus by adding this call to the initial AsyncTask we
> save that time when the directory is requested by native.
>
> This must only be called in the browser process as the sandbox
> processes do not need to make the call nor can they make the
> call(results in NPE).
>
> BUG=508615
>
> Committed: https://crrev.com/4a7568dffab924d3710a68949dca0717bdad3352
> Cr-Commit-Position: refs/heads/master@{#342672}

[email protected], [email protected]
[email protected], [email protected], [email protected]
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=508615

Review URL: https://codereview.chromium.org/1328043002

Cr-Commit-Position: refs/heads/master@{#347518}

Review URL: https://codereview.chromium.org/1315443012 .

Cr-Commit-Position: refs/branch-heads/2490@{#186}
Cr-Branched-From: 7790a35-refs/heads/master@{#344925}
  • Loading branch information
Daniel Sievers committed Sep 8, 2015
1 parent de4836c commit 32879e4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions base/android/java/src/org/chromium/base/PathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public abstract class PathUtils {
private static final int DATA_DIRECTORY = 0;
private static final int DATABASE_DIRECTORY = 1;
private static final int CACHE_DIRECTORY = 2;
private static final int DOWNLOADS_DIRECTORY = 3;
private static final int NUM_DIRECTORIES = 4;
private static final int NUM_DIRECTORIES = 3;
private static AsyncTask<String, Void, String[]> sDirPathFetchTask;

private static File sThumbnailDirectory;
Expand All @@ -50,10 +49,7 @@ protected String[] doInBackground(String... dataDirectorySuffix) {
paths[DATABASE_DIRECTORY] = appContext.getDatabasePath("foo").getParent();
// TODO(wnwen): Find a way to avoid calling this function in renderer process.
if (appContext.getCacheDir() != null) {
// These paths are only available in the browser process.
paths[CACHE_DIRECTORY] = appContext.getCacheDir().getPath();
paths[DOWNLOADS_DIRECTORY] = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS).getPath();
}
return paths;
}
Expand Down Expand Up @@ -119,8 +115,8 @@ public static String getThumbnailCacheDirectoryPath(Context appContext) {
@SuppressWarnings("unused")
@CalledByNative
private static String getDownloadsDirectory(Context appContext) {
assert sDirPathFetchTask != null : "setDataDirectorySuffix must be called first.";
return getDirectoryPath(DOWNLOADS_DIRECTORY);
return Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS).getPath();
}

/**
Expand Down

0 comments on commit 32879e4

Please sign in to comment.