OLD | NEW |
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.content.pm.ApplicationInfo; | 8 import android.content.pm.ApplicationInfo; |
9 import android.content.pm.PackageManager; | 9 import android.content.pm.PackageManager; |
10 import android.graphics.SurfaceTexture; | 10 import android.graphics.SurfaceTexture; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 private static BindingManager sBindingManager = BindingManagerImpl.createBin
dingManager(); | 344 private static BindingManager sBindingManager = BindingManagerImpl.createBin
dingManager(); |
345 | 345 |
346 // Map from surface id to Surface. | 346 // Map from surface id to Surface. |
347 private static Map<Integer, Surface> sViewSurfaceMap = | 347 private static Map<Integer, Surface> sViewSurfaceMap = |
348 new ConcurrentHashMap<Integer, Surface>(); | 348 new ConcurrentHashMap<Integer, Surface>(); |
349 | 349 |
350 // Map from surface texture id to Surface. | 350 // Map from surface texture id to Surface. |
351 private static Map<Pair<Integer, Integer>, Surface> sSurfaceTextureSurfaceMa
p = | 351 private static Map<Pair<Integer, Integer>, Surface> sSurfaceTextureSurfaceMa
p = |
352 new ConcurrentHashMap<Pair<Integer, Integer>, Surface>(); | 352 new ConcurrentHashMap<Pair<Integer, Integer>, Surface>(); |
353 | 353 |
| 354 // Whether the main application is currently brought to the foreground. |
| 355 private static boolean sApplicationInForeground = true; |
| 356 |
354 @VisibleForTesting | 357 @VisibleForTesting |
355 public static void setBindingManagerForTesting(BindingManager manager) { | 358 public static void setBindingManagerForTesting(BindingManager manager) { |
356 sBindingManager = manager; | 359 sBindingManager = manager; |
357 } | 360 } |
358 | 361 |
359 /** @return true iff the child process is protected from out-of-memory killi
ng */ | 362 /** @return true iff the child process is protected from out-of-memory killi
ng */ |
360 @CalledByNative | 363 @CalledByNative |
361 private static boolean isOomProtected(int pid) { | 364 private static boolean isOomProtected(int pid) { |
362 return sBindingManager.isOomProtected(pid); | 365 return sBindingManager.isOomProtected(pid); |
363 } | 366 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 * rely on renderer visibility signalled through setInForeground. See http:/
/crbug.com/421041. | 429 * rely on renderer visibility signalled through setInForeground. See http:/
/crbug.com/421041. |
427 */ | 430 */ |
428 public static void determinedVisibility(int pid) { | 431 public static void determinedVisibility(int pid) { |
429 sBindingManager.determinedVisibility(pid); | 432 sBindingManager.determinedVisibility(pid); |
430 } | 433 } |
431 | 434 |
432 /** | 435 /** |
433 * Called when the embedding application is sent to background. | 436 * Called when the embedding application is sent to background. |
434 */ | 437 */ |
435 public static void onSentToBackground() { | 438 public static void onSentToBackground() { |
| 439 sApplicationInForeground = false; |
436 sBindingManager.onSentToBackground(); | 440 sBindingManager.onSentToBackground(); |
437 } | 441 } |
438 | 442 |
439 /** | 443 /** |
440 * Called when the embedding application is brought to foreground. | 444 * Called when the embedding application is brought to foreground. |
441 */ | 445 */ |
442 public static void onBroughtToForeground() { | 446 public static void onBroughtToForeground() { |
| 447 sApplicationInForeground = true; |
443 sBindingManager.onBroughtToForeground(); | 448 sBindingManager.onBroughtToForeground(); |
444 } | 449 } |
445 | 450 |
446 /** | 451 /** |
| 452 * Returns whether the application is currently in the foreground. |
| 453 */ |
| 454 static boolean isApplicationInForeground() { |
| 455 return sApplicationInForeground; |
| 456 } |
| 457 |
| 458 /** |
447 * Should be called early in startup so the work needed to spawn the child p
rocess can be done | 459 * Should be called early in startup so the work needed to spawn the child p
rocess can be done |
448 * in parallel to other startup work. Must not be called on the UI thread. S
pare connection is | 460 * in parallel to other startup work. Must not be called on the UI thread. S
pare connection is |
449 * created in sandboxed child process. | 461 * created in sandboxed child process. |
450 * @param context the application context used for the connection. | 462 * @param context the application context used for the connection. |
451 */ | 463 */ |
452 public static void warmUp(Context context) { | 464 public static void warmUp(Context context) { |
453 synchronized (ChildProcessLauncher.class) { | 465 synchronized (ChildProcessLauncher.class) { |
454 assert !ThreadUtils.runningOnUiThread(); | 466 assert !ThreadUtils.runningOnUiThread(); |
455 if (sSpareSandboxedConnection == null) { | 467 if (sSpareSandboxedConnection == null) { |
456 sSpareSandboxedConnection = allocateBoundConnection(context, nul
l, true, false); | 468 sSpareSandboxedConnection = allocateBoundConnection(context, nul
l, true, false); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 } | 760 } |
749 | 761 |
750 return true; | 762 return true; |
751 } | 763 } |
752 | 764 |
753 private static native void nativeOnChildProcessStarted(long clientContext, i
nt pid); | 765 private static native void nativeOnChildProcessStarted(long clientContext, i
nt pid); |
754 private static native void nativeEstablishSurfacePeer( | 766 private static native void nativeEstablishSurfacePeer( |
755 int pid, Surface surface, int primaryID, int secondaryID); | 767 int pid, Surface surface, int primaryID, int secondaryID); |
756 private static native boolean nativeIsSingleProcess(); | 768 private static native boolean nativeIsSingleProcess(); |
757 } | 769 } |
OLD | NEW |