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

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

Issue 594603003: Infrastructure for reading V8's initial snapshot from external files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android tests Created 6 years, 2 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
Index: base/android/java/src/org/chromium/base/ResourceExtractor.java
diff --git a/base/android/java/src/org/chromium/base/ResourceExtractor.java b/base/android/java/src/org/chromium/base/ResourceExtractor.java
index 4cf155cbabdc8882047bf8b3380d4c781138c984..f3ec687d5930c615e5c74dd3d8a378622b09ccc4 100644
--- a/base/android/java/src/org/chromium/base/ResourceExtractor.java
+++ b/base/android/java/src/org/chromium/base/ResourceExtractor.java
@@ -36,6 +36,8 @@ public class ResourceExtractor {
private static final String LAST_LANGUAGE = "Last language";
private static final String PAK_FILENAMES = "Pak filenames";
private static final String ICU_DATA_FILENAME = "icudtl.dat";
+ private static final String V8_NATIVES_DATA_FILENAME = "natives_blob.bin";
+ private static final String V8_SNAPSHOT_DATA_FILENAME = "snapshot_blob.bin";
private static String[] sMandatoryPaks = null;
@@ -112,7 +114,11 @@ public class ResourceExtractor {
continue;
}
boolean isICUData = file.equals(ICU_DATA_FILENAME);
- File output = new File(isICUData ? getAppDataDir() : outputDir, file);
+ boolean isV8NativesData = file.equals(V8_NATIVES_DATA_FILENAME);
+ boolean isV8SnapshotData = file.equals(V8_SNAPSHOT_DATA_FILENAME);
rmcilroy 2014/10/06 15:41:02 Make this a single boolean (e.g., isAppDataFile)
baixo 2014/10/07 14:53:27 Done.
+ File output = new File(
+ (isICUData || isV8NativesData || isV8SnapshotData)
+ ? getAppDataDir() : outputDir, file);
if (output.exists()) {
continue;
}
@@ -138,7 +144,7 @@ public class ResourceExtractor {
throw new IOException(file + " extracted with 0 length!");
}
- if (!isICUData) {
+ if (!isICUData && !isV8NativesData && !isV8SnapshotData) {
filenames.add(file);
} else {
// icudata needs to be accessed by a renderer process.
rmcilroy 2014/10/06 15:41:02 nit - update comment
baixo 2014/10/07 14:53:27 Done.
@@ -274,18 +280,22 @@ public class ResourceExtractor {
* running the tests.
*/
@VisibleForTesting
- public void setExtractAllPaksForTesting() {
- List<String> pakFileAssets = new ArrayList<String>();
+ public void setExtractAllPaksAndV8SnapshotForTesting() {
+ List<String> pakAndSnapshotFileAssets = new ArrayList<String>();
AssetManager manager = mContext.getResources().getAssets();
try {
String[] files = manager.list("");
for (String file : files) {
- if (file.endsWith(".pak")) pakFileAssets.add(file);
+ if (file.endsWith(".pak")) pakAndSnapshotFileAssets.add(file);
}
} catch (IOException e) {
Log.w(LOGTAG, "Exception while accessing assets: " + e.getMessage(), e);
}
- setMandatoryPaksToExtract(pakFileAssets.toArray(new String[pakFileAssets.size()]));
+ pakAndSnapshotFileAssets.add("natives_blob.bin");
+ pakAndSnapshotFileAssets.add("snapshot_blob.bin");
+ setMandatoryPaksToExtract(
+ pakAndSnapshotFileAssets.toArray(
+ new String[pakAndSnapshotFileAssets.size()]));
}
private ResourceExtractor(Context context) {
@@ -343,12 +353,24 @@ public class ResourceExtractor {
* The ICU data (icudtl.dat) is less version-sensitive, but still can
* lead to malfunction/UX misbehavior. So, we regard failing to update them
* as an error.
+ * Failing to update the V8 snapshot files can also lead to misbehavior,
+ * so this is treated as an error as well.
rmcilroy 2014/10/06 15:41:02 nit - move this up above the ICU data sentence and
baixo 2014/10/07 14:53:27 Done.
*/
private void deleteFiles() {
File icudata = new File(getAppDataDir(), ICU_DATA_FILENAME);
if (icudata.exists() && !icudata.delete()) {
Log.e(LOGTAG, "Unable to remove the icudata " + icudata.getName());
}
+ File v8_natives = new File(getAppDataDir(), V8_NATIVES_DATA_FILENAME);
+ File v8_snapshot = new File(getAppDataDir(), V8_SNAPSHOT_DATA_FILENAME);
rmcilroy 2014/10/06 15:41:02 nit - move this down to line 370.
baixo 2014/10/07 14:53:27 Done.
+ if (v8_natives.exists() && !v8_natives.delete()) {
+ Log.e(LOGTAG,
+ "Unable to remove the v8 data " + v8_natives.getName());
+ }
+ if (v8_snapshot.exists() && !v8_snapshot.delete()) {
+ Log.e(LOGTAG,
+ "Unable to remove the v8 data " + v8_snapshot.getName());
+ }
File dir = getOutputDir();
if (dir.exists()) {
File[] files = dir.listFiles();

Powered by Google App Engine
This is Rietveld 408576698