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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/init/NativeInitializationController.java

Issue 2087043003: customtabs: Don't create an extra child process when one is already there. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.chrome.browser.init; 5 package org.chromium.chrome.browser.init;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.Looper; 10 import android.os.Looper;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 public NativeInitializationController(Context context, 65 public NativeInitializationController(Context context,
66 ChromeActivityNativeDelegate activityDelegate) { 66 ChromeActivityNativeDelegate activityDelegate) {
67 mContext = context.getApplicationContext(); 67 mContext = context.getApplicationContext();
68 mHandler = new Handler(Looper.getMainLooper()); 68 mHandler = new Handler(Looper.getMainLooper());
69 mActivityDelegate = activityDelegate; 69 mActivityDelegate = activityDelegate;
70 } 70 }
71 71
72 /** 72 /**
73 * Start loading the native library in the background. This kicks off the na tive initialization 73 * Start loading the native library in the background. This kicks off the na tive initialization
74 * process. 74 * process.
75 *
76 * @param allocateChildConnection Whether a spare child connection should be allocated. Set to
77 * false if you know that no new renderer is needed.
75 */ 78 */
76 public void startBackgroundTasks() { 79 public void startBackgroundTasks(final boolean allocateChildConnection) {
77 // TODO(yusufo) : Investigate using an AsyncTask for this. 80 // TODO(yusufo) : Investigate using an AsyncTask for this.
78 new Thread() { 81 new Thread() {
79 @Override 82 @Override
80 public void run() { 83 public void run() {
81 try { 84 try {
82 LibraryLoader libraryLoader = 85 LibraryLoader libraryLoader =
83 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER ); 86 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER );
84 libraryLoader.ensureInitialized(mContext.getApplicationConte xt()); 87 libraryLoader.ensureInitialized(mContext.getApplicationConte xt());
85 // The prefetch is done after the library load for two reaso ns: 88 // The prefetch is done after the library load for two reaso ns:
86 // - It is easier to know the library location after it has 89 // - It is easier to know the library location after it has
87 // been loaded. 90 // been loaded.
88 // - Testing has shown that this gives the best compromise, 91 // - Testing has shown that this gives the best compromise,
89 // by avoiding performance regression on any tested 92 // by avoiding performance regression on any tested
90 // device, and providing performance improvement on 93 // device, and providing performance improvement on
91 // some. Doing it earlier delays UI inflation and more 94 // some. Doing it earlier delays UI inflation and more
92 // generally startup on some devices, most likely by 95 // generally startup on some devices, most likely by
93 // competing for IO. 96 // competing for IO.
94 // For experimental results, see http://crbug.com/460438. 97 // For experimental results, see http://crbug.com/460438.
95 libraryLoader.asyncPrefetchLibrariesToMemory(); 98 libraryLoader.asyncPrefetchLibrariesToMemory();
96 } catch (ProcessInitException e) { 99 } catch (ProcessInitException e) {
97 Log.e(TAG, "Unable to load native library.", e); 100 Log.e(TAG, "Unable to load native library.", e);
98 mActivityDelegate.onStartupFailure(); 101 mActivityDelegate.onStartupFailure();
99 return; 102 return;
100 } 103 }
101 ChildProcessLauncher.warmUp(mContext); 104 if (allocateChildConnection) ChildProcessLauncher.warmUp(mContex t);
102 ThreadUtils.runOnUiThread(new Runnable() { 105 ThreadUtils.runOnUiThread(new Runnable() {
103 @Override 106 @Override
104 public void run() { 107 public void run() {
105 onLibraryLoaded(); 108 onLibraryLoaded();
106 } 109 }
107 }); 110 });
108 } 111 }
109 }.start(); 112 }.start();
110 } 113 }
111 114
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 ActivityResult activityResult; 264 ActivityResult activityResult;
262 for (int i = 0; i < mPendingActivityResults.size(); i++) { 265 for (int i = 0; i < mPendingActivityResults.size(); i++) {
263 activityResult = mPendingActivityResults.get(i); 266 activityResult = mPendingActivityResults.get(i);
264 mActivityDelegate.onActivityResultWithNative(activityResult.requ estCode, 267 mActivityDelegate.onActivityResultWithNative(activityResult.requ estCode,
265 activityResult.resultCode, activityResult.data); 268 activityResult.resultCode, activityResult.data);
266 } 269 }
267 mPendingActivityResults = null; 270 mPendingActivityResults = null;
268 } 271 }
269 } 272 }
270 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698