1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.chrome.browser;
7 import org.chromium.base.CalledByNative;
10 * Watches for when Chrome is told to restart itself.
12 public class ApplicationLifetime {
13 public interface Observer {
14 void onTerminate(boolean restart);
16 private static Observer sObserver = null;
19 * Sets the observer that monitors for ApplicationLifecycle events.
20 * We only allow one observer to be set to avoid race conditions for shutdown events.
22 public static void setObserver(Observer observer) {
23 assert sObserver == null;
28 * Removes whatever observer is currently watching this class.
30 public static void removeObserver() {
35 public static void terminate(boolean restart) {
36 if (sObserver != null)
37 sObserver.onTerminate(restart);