From 5f042d748484efcdac252f44469cb764c4decd3e Mon Sep 17 00:00:00 2001 From: agrieve Date: Wed, 24 Jun 2015 15:57:21 -0700 Subject: [PATCH] Do not require explicit initialization of ResourceExtractor It's used only for locale pack files now, so shouldn't require so much attention. This also removes the extraction args from ComponentsBrowserTestsApplication.java, which don't appear to be necessary BUG= Review URL: https://codereview.chromium.org/1181733004 Cr-Commit-Position: refs/heads/master@{#336020} --- .../chromium/WebViewChromiumFactoryProvider.java | 5 ---- .../android_webview/shell/AwShellApplication.java | 7 ------ .../src/org/chromium/base/ResourceExtractor.java | 27 ++-------------------- .../chromium/chromecast/shell/CastApplication.java | 2 -- .../ComponentsBrowserTestsApplication.java | 5 ---- .../ContentBrowserTestsApplication.java | 2 -- .../ChromiumLinkerTestApplication.java | 2 -- .../content_shell_apk/ContentShellApplication.java | 2 -- 8 files changed, 2 insertions(+), 50 deletions(-) diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java index 96ca680f79ea..c1d1658657da 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java @@ -41,7 +41,6 @@ import org.chromium.base.CommandLine; import org.chromium.base.MemoryPressureListener; import org.chromium.base.PathService; import org.chromium.base.PathUtils; -import org.chromium.base.ResourceExtractor; import org.chromium.base.ThreadUtils; import org.chromium.base.TraceEvent; import org.chromium.base.library_loader.LibraryLoader; @@ -230,10 +229,6 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { return; } - // We don't need to extract any paks because for WebView, they are - // in the system image. - ResourceExtractor.setMandatoryPaksToExtract(0); - try { LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitialized(); } catch (ProcessInitException e) { diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java index f6dc9a5f325c..9e847c5479e6 100644 --- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java +++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java @@ -10,7 +10,6 @@ import android.util.Log; import org.chromium.android_webview.AwBrowserProcess; import org.chromium.base.BaseSwitches; import org.chromium.base.CommandLine; -import org.chromium.base.ResourceExtractor; import org.chromium.base.TraceEvent; import org.chromium.content.app.ContentApplication; @@ -20,7 +19,6 @@ import org.chromium.content.app.ContentApplication; public class AwShellApplication extends ContentApplication { private static final String TAG = "AwShellApplication"; - /** The minimum set of .pak files the test runner needs. */ @Override public void onCreate() { @@ -45,11 +43,6 @@ public class AwShellApplication extends ContentApplication { } @Override - protected void initializeLibraryDependencies() { - ResourceExtractor.setMandatoryPaksToExtract(0); - } - - @Override public void initCommandLine() { throw new UnsupportedOperationException(); } diff --git a/base/android/java/src/org/chromium/base/ResourceExtractor.java b/base/android/java/src/org/chromium/base/ResourceExtractor.java index c11a0f2a5035..476d55056546 100644 --- a/base/android/java/src/org/chromium/base/ResourceExtractor.java +++ b/base/android/java/src/org/chromium/base/ResourceExtractor.java @@ -41,8 +41,8 @@ public class ResourceExtractor { 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; - private static int sLocalePaksResId = -1; + private static String[] sMandatoryPaks = new String[0]; + private static int sLocalePaksResId = 0; /** * Applies the reverse mapping done by locale_pak_resources.py. @@ -291,7 +291,6 @@ public class ResourceExtractor { * @param paths The list of paths to be extracted. */ public static void setMandatoryPaksToExtract(int localePaksResId, String... paths) { - // TODO(agrieve): Remove the need to call this once all files are loaded from the apk. assert (sInstance == null || sInstance.mExtractTask == null) : "Must be called before startExtractingResources is called"; sLocalePaksResId = localePaksResId; @@ -306,26 +305,6 @@ public class ResourceExtractor { setMandatoryPaksToExtract(0, paths); } - /** - * Marks all the 'pak' resources, packaged as assets, for extraction during - * running the tests. - */ - @VisibleForTesting - public void setExtractAllPaksAndV8SnapshotForTesting() { - List pakAndSnapshotFileAssets = new ArrayList(); - AssetManager manager = mContext.getResources().getAssets(); - try { - String[] files = manager.list(""); - for (String file : files) { - if (file.endsWith(".pak")) pakAndSnapshotFileAssets.add(file); - } - } catch (IOException e) { - Log.w(LOGTAG, "Exception while accessing assets: " + e.getMessage(), e); - } - setMandatoryPaksToExtract(0, pakAndSnapshotFileAssets.toArray( - new String[pakAndSnapshotFileAssets.size()])); - } - private ResourceExtractor(Context context) { mContext = context.getApplicationContext(); } @@ -454,8 +433,6 @@ public class ResourceExtractor { * Pak extraction not necessarily required by the embedder. */ private static boolean shouldSkipPakExtraction() { - assert (sLocalePaksResId != -1 && sMandatoryPaks != null) - : "setMandatoryPaksToExtract() must be called before startExtractingResources()"; return sMandatoryPaks.length == 0 && sLocalePaksResId == 0; } } diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java index 1d10edd4cf92..de9dddaecfb1 100644 --- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java +++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java @@ -10,7 +10,6 @@ import android.util.Log; import org.chromium.base.CommandLine; import org.chromium.base.PathUtils; -import org.chromium.base.ResourceExtractor; import org.chromium.content.app.ContentApplication; /** @@ -34,7 +33,6 @@ public class CastApplication extends ContentApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(0); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } diff --git a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java index a8387ce9f64f..bb40f1ff68e5 100644 --- a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java +++ b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java @@ -8,15 +8,11 @@ import android.content.Context; import org.chromium.base.BaseChromiumApplication; import org.chromium.base.PathUtils; -import org.chromium.base.ResourceExtractor; /** * A basic content browser tests {@link android.app.Application}. */ public class ComponentsBrowserTestsApplication extends BaseChromiumApplication { - private static final String[] MANDATORY_PAK_FILES = - new String[] {"components_tests_resources.pak", "content_shell.pak", "natives_blob.bin", - "snapshot_blob.bin"}; static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "components_shell"; @Override @@ -26,7 +22,6 @@ public class ComponentsBrowserTestsApplication extends BaseChromiumApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(0, MANDATORY_PAK_FILES); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } } diff --git a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java index 6cdd6d0beeb1..a6063c141a6f 100644 --- a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java +++ b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java @@ -8,7 +8,6 @@ import android.content.Context; import org.chromium.base.BaseChromiumApplication; import org.chromium.base.PathUtils; -import org.chromium.base.ResourceExtractor; /** * A basic content browser tests {@link android.app.Application}. @@ -24,7 +23,6 @@ public class ContentBrowserTestsApplication extends BaseChromiumApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(0); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } diff --git a/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java b/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java index a1d6482a211f..29cad9abf72c 100644 --- a/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java +++ b/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java @@ -8,7 +8,6 @@ import android.content.Context; import org.chromium.base.BaseChromiumApplication; import org.chromium.base.PathUtils; -import org.chromium.base.ResourceExtractor; /** * Application for testing the Chromium Linker @@ -24,7 +23,6 @@ public class ChromiumLinkerTestApplication extends BaseChromiumApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(0); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } diff --git a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java index 8cff2b165e05..04857e241b9d 100644 --- a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java +++ b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java @@ -6,7 +6,6 @@ package org.chromium.content_shell_apk; import org.chromium.base.CommandLine; import org.chromium.base.PathUtils; -import org.chromium.base.ResourceExtractor; import org.chromium.content.app.ContentApplication; /** @@ -25,7 +24,6 @@ public class ContentShellApplication extends ContentApplication { @Override protected void initializeLibraryDependencies() { - ResourceExtractor.setMandatoryPaksToExtract(0); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this); } -- 2.11.4.GIT