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

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/LicenseContentProvider.java

Issue 2006703004: Merge code which extracts assets from APK to file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | base/android/java/src/org/chromium/base/FileUtils.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/glue/java/src/com/android/webview/chromium/LicenseContentProvider.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/LicenseContentProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/LicenseContentProvider.java
index d07986f4ab932b97415ccd7f62948572172473b0..df14b51a32f7a731e787a955e14f3d5d92ef71ef 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/LicenseContentProvider.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/LicenseContentProvider.java
@@ -12,12 +12,10 @@ import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
-import java.io.BufferedOutputStream;
+import org.chromium.base.FileUtils;
+
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
/**
* Content provider for the OSS licenses file.
@@ -48,17 +46,7 @@ public class LicenseContentProvider extends ContentProvider {
private AssetFileDescriptor extractAsset(String name) throws IOException {
File extractedFile = new File(getContext().getCacheDir(), name);
if (!extractedFile.exists()) {
- InputStream inputStream = null;
- OutputStream outputStream = null;
- try {
- inputStream = getContext().getAssets().open(name);
- outputStream = new BufferedOutputStream(
- new FileOutputStream(extractedFile.getAbsolutePath()));
- copyStreams(inputStream, outputStream);
- } finally {
- if (inputStream != null) inputStream.close();
- if (outputStream != null) outputStream.close();
- }
+ FileUtils.extractAsset(getContext(), name, extractedFile);
}
ParcelFileDescriptor parcelFd =
ParcelFileDescriptor.open(extractedFile, ParcelFileDescriptor.MODE_READ_ONLY);
@@ -68,14 +56,6 @@ public class LicenseContentProvider extends ContentProvider {
return null;
}
- private static void copyStreams(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[8192];
- int c;
- while ((c = in.read(buffer)) != -1) {
- out.write(buffer, 0, c);
- }
- }
-
@Override
public String getType(Uri uri) {
if (uri != null && uri.toString().endsWith(LICENSES_URI_SUFFIX)) {
« no previous file with comments | « no previous file | base/android/java/src/org/chromium/base/FileUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698