OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.base.multidex; | 5 package org.chromium.base.multidex; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Build; | 8 import android.os.Build; |
9 import android.os.Process; | 9 import android.os.Process; |
10 import android.support.multidex.MultiDex; | 10 import android.support.multidex.MultiDex; |
11 | 11 |
12 import org.chromium.base.Log; | 12 import org.chromium.base.Log; |
13 import org.chromium.base.VisibleForTesting; | 13 import org.chromium.base.VisibleForTesting; |
14 | 14 |
15 import java.lang.reflect.InvocationTargetException; | 15 import java.lang.reflect.InvocationTargetException; |
16 | 16 |
17 /** | 17 /** |
18 * Performs multidex installation for non-isolated processes. | 18 * Performs multidex installation for non-isolated processes. |
19 */ | 19 */ |
20 public class ChromiumMultiDex { | 20 public class ChromiumMultiDex { |
21 | 21 |
22 private static final String TAG = "base_multidex"; | 22 private static final String TAG = "base_multidex"; |
23 | 23 |
24 /** | 24 /** |
25 * Installs secondary dexes if possible. | 25 * Installs secondary dexes if possible/necessary. |
26 * | 26 * |
27 * Isolated processes (e.g. renderer processes) can't load secondary dex fi
les on | 27 * Isolated processes (e.g. renderer processes) can't load secondary dex fi
les on |
28 * K and below, so we don't even try in that case. | 28 * K and below, so we don't even try in that case. |
29 * | 29 * |
| 30 * In release builds, this is a no-op because: |
| 31 * - multidex isn't necessary in release builds because we run proguard t
here and |
| 32 * thus aren't threatening to hit the dex limit; and |
| 33 * - calling MultiDex.install, even in the absence of secondary dexes, ca
uses a |
| 34 * significant regression in start-up time (crbug.com/525695). |
| 35 * |
30 * @param context The application context. | 36 * @param context The application context. |
31 */ | 37 */ |
32 @VisibleForTesting | 38 @VisibleForTesting |
33 #if defined(CONFIGURATION_NAME_Debug) | 39 #if defined(MULTIDEX_CONFIGURATION_Debug) |
34 public static void install(Context context) { | 40 public static void install(Context context) { |
35 try { | 41 try { |
36 // TODO(jbudorick): Back out this version check once support for K &
below works. | 42 // TODO(jbudorick): Back out this version check once support for K &
below works. |
37 // http://crbug.com/512357 | 43 // http://crbug.com/512357 |
38 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && processI
sIsolated()) { | 44 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && processI
sIsolated()) { |
39 Log.i(TAG, "Skipping multidex installation: inside isolated proc
ess."); | 45 Log.i(TAG, "Skipping multidex installation: inside isolated proc
ess."); |
40 } else { | 46 } else { |
41 MultiDex.install(context); | 47 MultiDex.install(context); |
42 Log.i(TAG, "Completed multidex installation."); | 48 Log.i(TAG, "Completed multidex installation."); |
43 } | 49 } |
(...skipping 10 matching lines...) Expand all Loading... |
54 private static boolean processIsIsolated() | 60 private static boolean processIsIsolated() |
55 throws NoSuchMethodException, IllegalAccessException, InvocationTarg
etException { | 61 throws NoSuchMethodException, IllegalAccessException, InvocationTarg
etException { |
56 return (boolean) Process.class.getMethod("isIsolated").invoke(null); | 62 return (boolean) Process.class.getMethod("isIsolated").invoke(null); |
57 } | 63 } |
58 #else | 64 #else |
59 public static void install(Context context) { | 65 public static void install(Context context) { |
60 } | 66 } |
61 #endif | 67 #endif |
62 | 68 |
63 } | 69 } |
OLD | NEW |