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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java

Issue 10693157: Add pak file support for content shell and android apks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve review comments. Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.app.ActivityManager; 7 import android.app.ActivityManager;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Resources; 9 import android.content.res.Resources;
10 import android.util.Log; 10 import android.util.Log;
11 11
12 import org.chromium.content.app.AppResource; 12 import org.chromium.content.app.AppResource;
13 import org.chromium.content.app.ContentMain; 13 import org.chromium.content.app.ContentMain;
14 import org.chromium.content.app.LibraryLoader; 14 import org.chromium.content.app.LibraryLoader;
15 import org.chromium.content.browser.ContentView; 15 import org.chromium.content.browser.ContentView;
16 import org.chromium.content.browser.ResourceExtractor;
16 import org.chromium.content.common.CommandLine; 17 import org.chromium.content.common.CommandLine;
17 18
18 // NOTE: This file hasn't been fully upstreamed, please don't merge to downstrea m. 19 // NOTE: This file hasn't been fully upstreamed, please don't merge to downstrea m.
19 public class AndroidBrowserProcess { 20 public class AndroidBrowserProcess {
20 21
21 private static final String TAG = "BrowserProcessMain"; 22 private static final String TAG = "BrowserProcessMain";
22 23
23 // Prevents initializing the process more than once. 24 // Prevents initializing the process more than once.
24 private static boolean sInitialized = false; 25 private static boolean sInitialized = false;
25 26
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 * @param maxRendererProcesses See ContentView.enableMultiProcess() 79 * @param maxRendererProcesses See ContentView.enableMultiProcess()
79 * @param hostIsChrome pass true if running as the system browser process. 80 * @param hostIsChrome pass true if running as the system browser process.
80 */ 81 */
81 private static void genericChromiumProcessInit(Context context, int maxRende rerProcesses, 82 private static void genericChromiumProcessInit(Context context, int maxRende rerProcesses,
82 boolean hostIsChrome) { 83 boolean hostIsChrome) {
83 if (sInitialized) { 84 if (sInitialized) {
84 return; 85 return;
85 } 86 }
86 sInitialized = true; 87 sInitialized = true;
87 88
89 // Normally Main.java will have kicked this off asynchronously for Chrom e. But
90 // other ContentView apps like tests also need them so we make sure we'v e
91 // extracted resources here. We can still make it a little async (wait u ntil
92 // the library is loaded).
93 ResourceExtractor resourceExtractor = ResourceExtractor.get(context);
94 resourceExtractor.startExtractingResources();
95
88 // Normally Main.java will have already loaded the library asynchronousl y, we only 96 // Normally Main.java will have already loaded the library asynchronousl y, we only
89 // need to load it here if we arrived via another flow, e.g. bookmark ac cess & sync setup. 97 // need to load it here if we arrived via another flow, e.g. bookmark ac cess & sync setup.
90 LibraryLoader.loadAndInitSync(); 98 LibraryLoader.loadAndInitSync();
91 99
92 Context appContext = context.getApplicationContext(); 100 Context appContext = context.getApplicationContext();
93 101
94 // This block is inside genericChromiumProcessInit() instead 102 // This block is inside genericChromiumProcessInit() instead
95 // of initChromiumBrowserProcess() to make sure we do it once. 103 // of initChromiumBrowserProcess() to make sure we do it once.
96 // In here it is protected with the sInitialized. 104 // In here it is protected with the sInitialized.
97 if (hostIsChrome) { 105 if (hostIsChrome) {
98 if (nativeIsOfficialBuild() || 106 if (nativeIsOfficialBuild() ||
99 CommandLine.getInstance().hasSwitch(CommandLine.ADD_OFFICIAL _COMMAND_LINE)) { 107 CommandLine.getInstance().hasSwitch(CommandLine.ADD_OFFICIAL _COMMAND_LINE)) {
100 Resources res = context.getResources(); 108 Resources res = context.getResources();
101 try { 109 try {
102 String[] switches = res.getStringArray(AppResource.ARRAY_OFF ICIAL_COMMAND_LINE); 110 String[] switches = res.getStringArray(AppResource.ARRAY_OFF ICIAL_COMMAND_LINE);
103 CommandLine.getInstance().appendSwitchesAndArguments(switche s); 111 CommandLine.getInstance().appendSwitchesAndArguments(switche s);
104 } catch (Resources.NotFoundException e) { 112 } catch (Resources.NotFoundException e) {
105 // Do nothing. It is fine to have no command line 113 // Do nothing. It is fine to have no command line
106 // additions for an official build. 114 // additions for an official build.
107 } 115 }
108 } 116 }
109 } 117 }
110 118
111 int maxRenderers = normalizeMaxRendererProcesses(appContext, maxRenderer Processes); 119 int maxRenderers = normalizeMaxRendererProcesses(appContext, maxRenderer Processes);
112 Log.i(TAG, "Initializing chromium process, renderers=" + maxRenderers + 120 Log.i(TAG, "Initializing chromium process, renderers=" + maxRenderers +
113 " hostIsChrome=" + hostIsChrome); 121 " hostIsChrome=" + hostIsChrome);
114 122
123 // Now we really need to have the resources ready.
124 resourceExtractor.waitForCompletion();
125
115 nativeSetCommandLineFlags(maxRenderers, getPlugins(context)); 126 nativeSetCommandLineFlags(maxRenderers, getPlugins(context));
116 ContentMain.initApplicationContext(appContext); 127 ContentMain.initApplicationContext(appContext);
117 ContentMain.start(); 128 ContentMain.start();
118 } 129 }
119 130
120 private static String getPlugins(final Context context) { 131 private static String getPlugins(final Context context) {
121 return ""; 132 return "";
122 } 133 }
123 134
124 private static native void nativeSetCommandLineFlags( 135 private static native void nativeSetCommandLineFlags(
125 int maxRenderProcesses, String plugin_descriptor); 136 int maxRenderProcesses, String plugin_descriptor);
126 137
127 // Is this an official build of Chrome? Only native code knows 138 // Is this an official build of Chrome? Only native code knows
128 // for sure. Official build knowledge is needed very early in 139 // for sure. Official build knowledge is needed very early in
129 // process startup. 140 // process startup.
130 private static native boolean nativeIsOfficialBuild(); 141 private static native boolean nativeIsOfficialBuild();
131 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698