OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.init; | 5 package org.chromium.chrome.browser.init; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.os.Process; | 10 import android.os.Process; |
(...skipping 17 matching lines...) Expand all Loading... |
28 * https://crbug.com/515919 details why another Activity is used instead of usin
g the AlarmManager. | 28 * https://crbug.com/515919 details why another Activity is used instead of usin
g the AlarmManager. |
29 * https://crbug.com/545453 details why the BrowserRestartActivity handles the p
rocess killing. | 29 * https://crbug.com/545453 details why the BrowserRestartActivity handles the p
rocess killing. |
30 */ | 30 */ |
31 class ChromeLifetimeController implements ApplicationLifetime.Observer, | 31 class ChromeLifetimeController implements ApplicationLifetime.Observer, |
32 ApplicationStatus.ActivityStateListener { | 32 ApplicationStatus.ActivityStateListener { |
33 private static final String TAG = "LifetimeController"; | 33 private static final String TAG = "LifetimeController"; |
34 | 34 |
35 private static ChromeLifetimeController sInstance; | 35 private static ChromeLifetimeController sInstance; |
36 | 36 |
37 private boolean mRestartChromeOnDestroy; | 37 private boolean mRestartChromeOnDestroy; |
38 private int mRemainingActivitiesCount = 0; | 38 private int mRemainingActivitiesCount; |
39 | 39 |
40 /** | 40 /** |
41 * Initialize the ChromeLifetimeController; | 41 * Initialize the ChromeLifetimeController; |
42 */ | 42 */ |
43 @SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC") | 43 @SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC") |
44 public static void initialize() { | 44 public static void initialize() { |
45 ThreadUtils.assertOnUiThread(); | 45 ThreadUtils.assertOnUiThread(); |
46 if (sInstance != null) return; | 46 if (sInstance != null) return; |
47 sInstance = new ChromeLifetimeController(); | 47 sInstance = new ChromeLifetimeController(); |
48 ApplicationLifetime.addObserver(sInstance); | 48 ApplicationLifetime.addObserver(sInstance); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 Intent intent = new Intent(); | 83 Intent intent = new Intent(); |
84 intent.setAction(action); | 84 intent.setAction(action); |
85 intent.setClassName( | 85 intent.setClassName( |
86 context.getPackageName(), BrowserRestartActivity.class.getName()
); | 86 context.getPackageName(), BrowserRestartActivity.class.getName()
); |
87 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 87 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
88 intent.putExtra(BrowserRestartActivity.EXTRA_MAIN_PID, Process.myPid()); | 88 intent.putExtra(BrowserRestartActivity.EXTRA_MAIN_PID, Process.myPid()); |
89 intent.putExtra(BrowserRestartActivity.EXTRA_RESTART, mRestartChromeOnDe
stroy); | 89 intent.putExtra(BrowserRestartActivity.EXTRA_RESTART, mRestartChromeOnDe
stroy); |
90 context.startActivity(intent); | 90 context.startActivity(intent); |
91 } | 91 } |
92 } | 92 } |
OLD | NEW |