Index: chrome/android/java/src/org/chromium/chrome/browser/ApplicationLifetime.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ApplicationLifetime.java b/chrome/android/java/src/org/chromium/chrome/browser/ApplicationLifetime.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..350f3aee2d88ead6ddb97ff0ae777bada5aa8209 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ApplicationLifetime.java |
@@ -0,0 +1,32 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser; |
+ |
+import org.chromium.base.CalledByNative; |
+ |
+/** |
+ * Watches for when Chrome is told to restart itself. |
+ */ |
+public class ApplicationLifetime { |
+ public interface Observer { |
+ void onTerminate(boolean restart); |
+ } |
+ private static Observer sObserver = null; |
+ |
+ /** |
+ * Sets the observer that monitors for ApplicationLifecycle events. |
+ * We only allow one observer to be set to avoid race conditions for shutdown events. |
+ */ |
+ public static void setObserver(Observer observer) { |
+ assert sObserver == null; |
+ sObserver = observer; |
+ } |
+ |
+ @CalledByNative |
+ public static void terminate(boolean restart) { |
+ if (sObserver != null) |
+ sObserver.onTerminate(restart); |
+ } |
+} |