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

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

Issue 2849943002: android: Remove sBindingManagerLock (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.os.IBinder; 9 import android.os.IBinder;
10 import android.os.RemoteException; 10 import android.os.RemoteException;
11 11
12 import org.chromium.base.CpuFeatures; 12 import org.chromium.base.CpuFeatures;
13 import org.chromium.base.Log; 13 import org.chromium.base.Log;
14 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
15 import org.chromium.base.TraceEvent; 15 import org.chromium.base.TraceEvent;
16 import org.chromium.base.VisibleForTesting; 16 import org.chromium.base.VisibleForTesting;
17 import org.chromium.base.annotations.SuppressFBWarnings;
17 import org.chromium.base.library_loader.Linker; 18 import org.chromium.base.library_loader.Linker;
18 import org.chromium.base.process_launcher.ChildProcessCreationParams; 19 import org.chromium.base.process_launcher.ChildProcessCreationParams;
19 import org.chromium.base.process_launcher.FileDescriptorInfo; 20 import org.chromium.base.process_launcher.FileDescriptorInfo;
20 import org.chromium.content.app.ChromiumLinkerParams; 21 import org.chromium.content.app.ChromiumLinkerParams;
21 import org.chromium.content.common.ContentSwitches; 22 import org.chromium.content.common.ContentSwitches;
22 23
23 import java.util.Map; 24 import java.util.Map;
24 import java.util.concurrent.ConcurrentHashMap; 25 import java.util.concurrent.ConcurrentHashMap;
25 26
26 /** 27 /**
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 }); 176 });
176 } 177 }
177 } 178 }
178 }, FREE_CONNECTION_DELAY_MILLIS); 179 }, FREE_CONNECTION_DELAY_MILLIS);
179 } 180 }
180 181
181 // Map from pid to ChildService connection. 182 // Map from pid to ChildService connection.
182 private static Map<Integer, BaseChildProcessConnection> sServiceMap = 183 private static Map<Integer, BaseChildProcessConnection> sServiceMap =
183 new ConcurrentHashMap<Integer, BaseChildProcessConnection>(); 184 new ConcurrentHashMap<Integer, BaseChildProcessConnection>();
184 185
185 // Lock for getBindingManager()
186 private static final Object sBindingManagerLock = new Object();
187
188 // These variables are used for the warm up sandboxed connection. 186 // These variables are used for the warm up sandboxed connection.
189 // |sSpareSandboxedConnection| is non-null when there is a pending connectio n. Note it's cleared 187 // |sSpareSandboxedConnection| is non-null when there is a pending connectio n. Note it's cleared
190 // to null again after the connection is used for a real child process. 188 // to null again after the connection is used for a real child process.
191 // |sSpareConnectionStarting| is true if ChildProcessConnection.StartCallbac k has not fired. 189 // |sSpareConnectionStarting| is true if ChildProcessConnection.StartCallbac k has not fired.
192 // This is used for a child process allocation to determine if StartCallback should be chained. 190 // This is used for a child process allocation to determine if StartCallback should be chained.
193 // |sSpareConnectionStartCallback| is the chained StartCallback. This is als o used to determine 191 // |sSpareConnectionStartCallback| is the chained StartCallback. This is als o used to determine
194 // if there is already a child process launch that's used this this connecti on. 192 // if there is already a child process launch that's used this this connecti on.
195 private static BaseChildProcessConnection sSpareSandboxedConnection; 193 private static BaseChildProcessConnection sSpareSandboxedConnection;
196 private static boolean sSpareConnectionStarting; 194 private static boolean sSpareConnectionStarting;
197 private static BaseChildProcessConnection.StartCallback sSpareConnectionStar tCallback; 195 private static BaseChildProcessConnection.StartCallback sSpareConnectionStar tCallback;
198 196
199 // Manages oom bindings used to bind chind services. Lazily initialized by g etBindingManager() 197 // Manages oom bindings used to bind chind services. Lazily initialized by g etBindingManager()
200 private static BindingManager sBindingManager; 198 private static BindingManager sBindingManager;
201 199
202 // Whether the main application is currently brought to the foreground. 200 // Whether the main application is currently brought to the foreground.
203 private static boolean sApplicationInForeground = true; 201 private static boolean sApplicationInForeground = true;
204 202
205 // Lazy initialize sBindingManager 203 // Lazy initialize sBindingManager
206 // TODO(boliu): This should be internal to content. 204 // TODO(boliu): This should be internal to content.
205 @SuppressFBWarnings("LI_LAZY_INIT_STATIC") // Method is single thread.
207 public static BindingManager getBindingManager() { 206 public static BindingManager getBindingManager() {
208 synchronized (sBindingManagerLock) { 207 assert LauncherThread.runningOnLauncherThread();
209 if (sBindingManager == null) { 208 if (sBindingManager == null) {
210 sBindingManager = BindingManagerImpl.createBindingManager(); 209 sBindingManager = BindingManagerImpl.createBindingManager();
211 }
212 return sBindingManager;
213 } 210 }
211 return sBindingManager;
214 } 212 }
215 213
216 @VisibleForTesting 214 @VisibleForTesting
217 public static void setBindingManagerForTesting(BindingManager manager) { 215 public static void setBindingManagerForTesting(BindingManager manager) {
218 sBindingManager = manager; 216 sBindingManager = manager;
219 } 217 }
220 218
221 /** 219 /**
222 * Called when the renderer commits a navigation. This signals a time at whi ch it is safe to 220 * Called when the renderer commits a navigation. This signals a time at whi ch it is safe to
223 * rely on renderer visibility signalled through setInForeground. See http:/ /crbug.com/421041. 221 * rely on renderer visibility signalled through setInForeground. See http:/ /crbug.com/421041.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 551
554 try { 552 try {
555 ((ManagedChildProcessConnection) sServiceMap.get(pid)).crashServiceF orTesting(); 553 ((ManagedChildProcessConnection) sServiceMap.get(pid)).crashServiceF orTesting();
556 } catch (RemoteException ex) { 554 } catch (RemoteException ex) {
557 return false; 555 return false;
558 } 556 }
559 557
560 return true; 558 return true;
561 } 559 }
562 } 560 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698