Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: base/android/java/src/org/chromium/base/PathUtils.java

Issue 1281273003: Pre-cache downloads directory path in PathUtils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/PathUtils.java
diff --git a/base/android/java/src/org/chromium/base/PathUtils.java b/base/android/java/src/org/chromium/base/PathUtils.java
index 8d676fa850e82604d5cb8523aa87094809cf204c..05697e2bbceafcdc0e29e5f8958887dd9177080a 100644
--- a/base/android/java/src/org/chromium/base/PathUtils.java
+++ b/base/android/java/src/org/chromium/base/PathUtils.java
@@ -23,7 +23,8 @@ 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 NUM_DIRECTORIES = 3;
+ private static final int DOWNLOADS_DIRECTORY = 3;
+ private static final int NUM_DIRECTORIES = 4;
private static AsyncTask<String, Void, String[]> sDirPathFetchTask;
private static File sThumbnailDirectory;
@@ -49,7 +50,10 @@ public abstract class PathUtils {
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;
}
@@ -115,8 +119,8 @@ public abstract class PathUtils {
@SuppressWarnings("unused")
@CalledByNative
private static String getDownloadsDirectory(Context appContext) {
- return Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_DOWNLOADS).getPath();
+ assert sDirPathFetchTask != null : "setDataDirectorySuffix must be called first.";
+ return getDirectoryPath(DOWNLOADS_DIRECTORY);
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698