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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
10 import android.os.StrictMode; | 10 import android.os.StrictMode; |
11 | 11 |
12 import com.google.android.gms.gcm.GcmNetworkManager; | 12 import com.google.android.gms.gcm.GcmNetworkManager; |
13 import com.google.android.gms.gcm.OneoffTask; | 13 import com.google.android.gms.gcm.OneoffTask; |
14 import com.google.android.gms.gcm.Task; | 14 import com.google.android.gms.gcm.Task; |
15 | 15 |
16 import org.chromium.base.ContextUtils; | 16 import org.chromium.base.ContextUtils; |
17 import org.chromium.base.Log; | 17 import org.chromium.base.Log; |
18 import org.chromium.base.VisibleForTesting; | 18 import org.chromium.base.VisibleForTesting; |
19 import org.chromium.base.annotations.CalledByNative; | 19 import org.chromium.base.annotations.CalledByNative; |
20 import org.chromium.base.annotations.SuppressFBWarnings; | |
21 import org.chromium.base.metrics.RecordHistogram; | 20 import org.chromium.base.metrics.RecordHistogram; |
22 import org.chromium.chrome.browser.externalauth.ExternalAuthUtils; | 21 import org.chromium.chrome.browser.externalauth.ExternalAuthUtils; |
23 import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler; | 22 import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler; |
24 | 23 |
25 /** | 24 /** |
26 * The {@link BackgroundSyncLauncher} singleton is created and owned by the C++
browser. It | 25 * The {@link BackgroundSyncLauncher} singleton is created and owned by the C++
browser. It |
27 * registers interest in waking up the browser the next time the device goes onl
ine after the | 26 * registers interest in waking up the browser the next time the device goes onl
ine after the |
28 * browser closes via the {@link #launchBrowserIfStopped} method. | 27 * browser closes via the {@link #launchBrowserIfStopped} method. |
29 * | 28 * |
30 * Thread model: This class is to be run on the UI thread only. | 29 * Thread model: This class is to be run on the UI thread only. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 throw new IllegalStateException("Already instantiated"); | 63 throw new IllegalStateException("Already instantiated"); |
65 } | 64 } |
66 | 65 |
67 sInstance = new BackgroundSyncLauncher(); | 66 sInstance = new BackgroundSyncLauncher(); |
68 return sInstance; | 67 return sInstance; |
69 } | 68 } |
70 | 69 |
71 /** | 70 /** |
72 * Called when the C++ counterpart is deleted. | 71 * Called when the C++ counterpart is deleted. |
73 */ | 72 */ |
74 @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") | |
75 @VisibleForTesting | 73 @VisibleForTesting |
76 @CalledByNative | 74 @CalledByNative |
77 protected void destroy() { | 75 protected void destroy() { |
78 assert sInstance == this; | 76 assert sInstance == this; |
79 sInstance = null; | 77 sInstance = null; |
80 } | 78 } |
81 | 79 |
82 /** | 80 /** |
83 * Callback for {@link #shouldLaunchBrowserIfStopped}. The run method is inv
oked on the UI | 81 * Callback for {@link #shouldLaunchBrowserIfStopped}. The run method is inv
oked on the UI |
84 * thread. | 82 * thread. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 261 } |
264 }; | 262 }; |
265 BackgroundSyncLauncher.shouldLaunchBrowserIfStopped(callback); | 263 BackgroundSyncLauncher.shouldLaunchBrowserIfStopped(callback); |
266 } | 264 } |
267 | 265 |
268 @VisibleForTesting | 266 @VisibleForTesting |
269 static void setGCMEnabled(boolean enabled) { | 267 static void setGCMEnabled(boolean enabled) { |
270 sGCMEnabled = enabled; | 268 sGCMEnabled = enabled; |
271 } | 269 } |
272 } | 270 } |
OLD | NEW |