diff options
author | wnwen <wnwen@chromium.org> | 2015-04-21 10:43:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-21 17:43:54 +0000 |
commit | 23911c85198ae5dd2ed9d7046d5106e3982d1f2e (patch) | |
tree | 20c4cbd624e848134e9639549974781452634ecd /base | |
parent | de60c5f1d99db33d563c6ccc42d0a27d504a3bcc (diff) | |
download | chromium_src-23911c85198ae5dd2ed9d7046d5106e3982d1f2e.zip chromium_src-23911c85198ae5dd2ed9d7046d5106e3982d1f2e.tar.gz chromium_src-23911c85198ae5dd2ed9d7046d5106e3982d1f2e.tar.bz2 |
Migrate the rest of PathUtils calls to run in background.
Follow-up for http://crrev.com/1091843002, to have all callers start async tasks
in order to fetch directory paths to avoid I/O on the UI thread.
BUG=473353
Review URL: https://codereview.chromium.org/1093223002
Cr-Commit-Position: refs/heads/master@{#326065}
Diffstat (limited to 'base')
-rw-r--r-- | base/android/java/src/org/chromium/base/PathUtils.java | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/base/android/java/src/org/chromium/base/PathUtils.java b/base/android/java/src/org/chromium/base/PathUtils.java index bcd850c..edaa634 100644 --- a/base/android/java/src/org/chromium/base/PathUtils.java +++ b/base/android/java/src/org/chromium/base/PathUtils.java @@ -16,8 +16,6 @@ import java.util.concurrent.ExecutionException; */ public abstract class PathUtils { - private static String sDataDirectorySuffix; - private static final int DATA_DIRECTORY = 0; private static final int DATABASE_DIRECTORY = 1; private static final int CACHE_DIRECTORY = 2; @@ -28,22 +26,6 @@ public abstract class PathUtils { private PathUtils() {} /** - * Sets the suffix that should be used for the directory where private data is to be stored - * by the application. - * - * TODO(wnwen): Remove this after all clients have migrated and add asserts for not null. - * - * @param suffix The private data directory suffix. - * @see Context#getDir(String, int) - * @deprecated - */ - @Deprecated - public static void setPrivateDataDirectorySuffix(String suffix) { - sDirPathFetchTask = null; - sDataDirectorySuffix = suffix; - } - - /** * Starts an asynchronous task to fetch the path of the directory where private data is to be * stored by the application. * @@ -51,7 +33,6 @@ public abstract class PathUtils { * @see Context#getDir(String, int) */ public static void setPrivateDataDirectorySuffix(String suffix, final Context appContext) { - sDataDirectorySuffix = null; sDirPathFetchTask = new AsyncTask<String, Void, String[]>() { @Override protected String[] doInBackground(String... dataDirectorySuffix) { @@ -83,15 +64,8 @@ public abstract class PathUtils { */ @CalledByNative public static String getDataDirectory(Context appContext) { - if (sDataDirectorySuffix == null && sDirPathFetchTask == null) { - throw new IllegalStateException( - "setDataDirectorySuffix must be called before getDataDirectory"); - } else if (sDirPathFetchTask != null) { - return getDirectoryPath(DATA_DIRECTORY); - } else { - // Temporarily allow UI thread directory fetching until all callers have been migrated. - return appContext.getDir(sDataDirectorySuffix, Context.MODE_PRIVATE).getPath(); - } + assert sDirPathFetchTask != null : "setDataDirectorySuffix must be called first."; + return getDirectoryPath(DATA_DIRECTORY); } /** @@ -99,11 +73,8 @@ public abstract class PathUtils { */ @CalledByNative public static String getDatabaseDirectory(Context appContext) { - if (sDirPathFetchTask != null) { - return getDirectoryPath(DATABASE_DIRECTORY); - } - // Context.getDatabasePath() returns path for the provided filename. - return appContext.getDatabasePath("foo").getParent(); + assert sDirPathFetchTask != null : "setDataDirectorySuffix must be called first."; + return getDirectoryPath(DATABASE_DIRECTORY); } /** @@ -112,10 +83,8 @@ public abstract class PathUtils { @SuppressWarnings("unused") @CalledByNative public static String getCacheDirectory(Context appContext) { - if (sDirPathFetchTask != null) { - return getDirectoryPath(CACHE_DIRECTORY); - } - return appContext.getCacheDir().getPath(); + assert sDirPathFetchTask != null : "setDataDirectorySuffix must be called first."; + return getDirectoryPath(CACHE_DIRECTORY); } /** |