| 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..46f1ebc8bd8c9329ba01ab4453791e775d034812
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ApplicationLifetime.java
|
| @@ -0,0 +1,39 @@
|
| +// 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;
|
| + }
|
| +
|
| + /**
|
| + * Removes whatever observer is currently watching this class.
|
| + */
|
| + public static void removeObserver() {
|
| + sObserver = null;
|
| + }
|
| +
|
| + @CalledByNative
|
| + public static void terminate(boolean restart) {
|
| + if (sObserver != null)
|
| + sObserver.onTerminate(restart);
|
| + }
|
| +}
|
|
|