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

Unified Diff: shell/android/apk/src/org/chromium/mojo_shell_apk/FileHelper.java

Issue 782013002: Android: decouple mojo shell from the network service. (Closed) Base URL: https://github.com/domokit/mojo.git@build-rule-for-the-network-service
Patch Set: Rebase. Created 6 years 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
Index: shell/android/apk/src/org/chromium/mojo_shell_apk/FileHelper.java
diff --git a/shell/android/apk/src/org/chromium/mojo_shell_apk/FileHelper.java b/shell/android/apk/src/org/chromium/mojo_shell_apk/FileHelper.java
index 70f95e1f13dc5e37248b04ee9c123ba7fb10a00b..44d9306b6dd979a3981b4cc363e58ee5f2cc6210 100644
--- a/shell/android/apk/src/org/chromium/mojo_shell_apk/FileHelper.java
+++ b/shell/android/apk/src/org/chromium/mojo_shell_apk/FileHelper.java
@@ -27,12 +27,18 @@ class FileHelper {
// Prefix used when naming temporary files.
private static final String TEMP_FILE_PREFIX = "temp-";
- static File extractFromAssets(Context context, String assetName, File outputDirectory)
- throws IOException, FileNotFoundException {
- // Make the original filename part of the temp file name.
- // TODO(ppi): do we need to sanitize the suffix?
- String suffix = "-" + assetName;
- File outputFile = File.createTempFile(TEMP_FILE_PREFIX, suffix, outputDirectory);
+ static File extractFromAssets(Context context, String assetName, File outputDirectory,
+ boolean useTempFile) throws IOException, FileNotFoundException {
+ File outputFile;
+ if (useTempFile) {
+ // Make the original filename part of the temp file name.
+ // TODO(ppi): do we need to sanitize the suffix?
+ String suffix = "-" + assetName;
+ outputFile = File.createTempFile(TEMP_FILE_PREFIX, suffix, outputDirectory);
+ } else {
+ outputFile = new File(outputDirectory, assetName);
+ }
+
BufferedInputStream inputStream = new BufferedInputStream(
context.getAssets().open(assetName));
writeStreamToFile(inputStream, outputFile);

Powered by Google App Engine
This is Rietveld 408576698