OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.os.AsyncTask; | 9 import android.os.AsyncTask; |
10 import android.os.Handler; | 10 import android.os.Handler; |
11 import android.os.Looper; | 11 import android.os.Looper; |
12 import android.os.Process; | 12 import android.os.Process; |
13 import android.preference.PreferenceManager; | 13 import android.preference.PreferenceManager; |
14 import android.text.TextUtils; | 14 import android.text.TextUtils; |
15 | 15 |
16 import com.squareup.leakcanary.LeakCanary; | |
17 | |
18 import org.chromium.base.ActivityState; | 16 import org.chromium.base.ActivityState; |
19 import org.chromium.base.ApplicationStatus; | 17 import org.chromium.base.ApplicationStatus; |
20 import org.chromium.base.ApplicationStatus.ActivityStateListener; | 18 import org.chromium.base.ApplicationStatus.ActivityStateListener; |
21 import org.chromium.base.BaseSwitches; | 19 import org.chromium.base.BaseSwitches; |
22 import org.chromium.base.CommandLine; | 20 import org.chromium.base.CommandLine; |
23 import org.chromium.base.ContentUriUtils; | 21 import org.chromium.base.ContentUriUtils; |
| 22 import org.chromium.base.LeakCanaryUtil; |
24 import org.chromium.base.Log; | 23 import org.chromium.base.Log; |
25 import org.chromium.base.ResourceExtractor; | 24 import org.chromium.base.ResourceExtractor; |
26 import org.chromium.base.ThreadUtils; | 25 import org.chromium.base.ThreadUtils; |
27 import org.chromium.base.TraceEvent; | 26 import org.chromium.base.TraceEvent; |
28 import org.chromium.base.annotations.RemovableInRelease; | |
29 import org.chromium.base.library_loader.LibraryLoader; | 27 import org.chromium.base.library_loader.LibraryLoader; |
30 import org.chromium.base.library_loader.LibraryProcessType; | 28 import org.chromium.base.library_loader.LibraryProcessType; |
31 import org.chromium.base.library_loader.ProcessInitException; | 29 import org.chromium.base.library_loader.ProcessInitException; |
32 import org.chromium.chrome.browser.ChromeApplication; | 30 import org.chromium.chrome.browser.ChromeApplication; |
33 import org.chromium.chrome.browser.ChromeStrictMode; | 31 import org.chromium.chrome.browser.ChromeStrictMode; |
34 import org.chromium.chrome.browser.ChromeSwitches; | 32 import org.chromium.chrome.browser.ChromeSwitches; |
35 import org.chromium.chrome.browser.ChromeVersionInfo; | 33 import org.chromium.chrome.browser.ChromeVersionInfo; |
36 import org.chromium.chrome.browser.FileProviderHelper; | 34 import org.chromium.chrome.browser.FileProviderHelper; |
37 import org.chromium.chrome.browser.crash.MinidumpDirectoryObserver; | 35 import org.chromium.chrome.browser.crash.MinidumpDirectoryObserver; |
38 import org.chromium.chrome.browser.device.DeviceClassManager; | 36 import org.chromium.chrome.browser.device.DeviceClassManager; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 public static ChromeBrowserInitializer getInstance(Context context) { | 87 public static ChromeBrowserInitializer getInstance(Context context) { |
90 if (sChromeBrowserInitiliazer == null) { | 88 if (sChromeBrowserInitiliazer == null) { |
91 sChromeBrowserInitiliazer = new ChromeBrowserInitializer(context); | 89 sChromeBrowserInitiliazer = new ChromeBrowserInitializer(context); |
92 } | 90 } |
93 return sChromeBrowserInitiliazer; | 91 return sChromeBrowserInitiliazer; |
94 } | 92 } |
95 | 93 |
96 private ChromeBrowserInitializer(Context context) { | 94 private ChromeBrowserInitializer(Context context) { |
97 mApplication = (ChromeApplication) context.getApplicationContext(); | 95 mApplication = (ChromeApplication) context.getApplicationContext(); |
98 mHandler = new Handler(Looper.getMainLooper()); | 96 mHandler = new Handler(Looper.getMainLooper()); |
99 initLeakCanary(); | 97 LeakCanaryUtil.initialize(mApplication); |
100 } | |
101 | |
102 @RemovableInRelease | |
103 private void initLeakCanary() { | |
104 // Watch that Activity objects are not retained after their onDestroy()
has been called. | |
105 // This is a no-op in release builds. | |
106 LeakCanary.install(mApplication); | |
107 } | 98 } |
108 | 99 |
109 /** | 100 /** |
110 * Initializes the Chrome browser process synchronously. | 101 * Initializes the Chrome browser process synchronously. |
111 * | 102 * |
112 * @throws ProcessInitException if there is a problem with the native librar
y. | 103 * @throws ProcessInitException if there is a problem with the native librar
y. |
113 */ | 104 */ |
114 public void handleSynchronousStartup() throws ProcessInitException { | 105 public void handleSynchronousStartup() throws ProcessInitException { |
115 assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on
the wrong thread"; | 106 assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on
the wrong thread"; |
116 | 107 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // stale natively-loaded resources are not reloaded (http://
crbug.com/552618). | 395 // stale natively-loaded resources are not reloaded (http://
crbug.com/552618). |
405 if (!mInitialLocale.equals(Locale.getDefault())) { | 396 if (!mInitialLocale.equals(Locale.getDefault())) { |
406 Log.e(TAG, "Killing process because of locale change."); | 397 Log.e(TAG, "Killing process because of locale change."); |
407 Process.killProcess(Process.myPid()); | 398 Process.killProcess(Process.myPid()); |
408 } | 399 } |
409 } | 400 } |
410 } | 401 } |
411 }; | 402 }; |
412 } | 403 } |
413 } | 404 } |
OLD | NEW |