jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
iclelland | 8467f46 | 2015-10-21 14:03:13 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_ |
| 6 | #define CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_ |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 7 | |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 10 | #include <set> |
| 11 | |
| 12 | #include "base/android/jni_android.h" |
| 13 | #include "base/lazy_instance.h" |
| 14 | #include "base/macros.h" |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 15 | |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 16 | // The BackgroundSyncLauncherAndroid singleton owns the Java |
| 17 | // BackgroundSyncLauncher object and is used to register interest in starting |
| 18 | // the browser the next time the device goes online. This class runs on the UI |
| 19 | // thread. |
iclelland | 8467f46 | 2015-10-21 14:03:13 | [diff] [blame] | 20 | class BackgroundSyncLauncherAndroid { |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 21 | public: |
| 22 | static BackgroundSyncLauncherAndroid* Get(); |
| 23 | |
jkarlin | 4302d71 | 2015-11-10 10:59:01 | [diff] [blame] | 24 | static void LaunchBrowserIfStopped(bool launch_when_next_online, |
| 25 | int64_t min_delay_ms); |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 26 | |
iclelland | d054a6f | 2016-01-11 20:16:14 | [diff] [blame] | 27 | static bool ShouldDisableBackgroundSync(); |
| 28 | |
| 29 | // TODO(iclelland): Remove this once the bots have their play services package |
| 30 | // updated before every test run. (https://crbug.com/514449) |
| 31 | static void SetPlayServicesVersionCheckDisabledForTests(bool disabled); |
| 32 | |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 33 | private: |
scottmg | 5e65e3a | 2017-03-08 08:48:46 | [diff] [blame^] | 34 | friend struct base::LazyInstanceTraitsBase<BackgroundSyncLauncherAndroid>; |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 35 | |
| 36 | // Constructor and destructor marked private to enforce singleton |
| 37 | BackgroundSyncLauncherAndroid(); |
| 38 | ~BackgroundSyncLauncherAndroid(); |
| 39 | |
jkarlin | 4302d71 | 2015-11-10 10:59:01 | [diff] [blame] | 40 | void LaunchBrowserIfStoppedImpl(bool launch_when_next_online, |
| 41 | int64_t min_delay_ms); |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 42 | |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 43 | base::android::ScopedJavaGlobalRef<jobject> java_launcher_; |
| 44 | DISALLOW_COPY_AND_ASSIGN(BackgroundSyncLauncherAndroid); |
| 45 | }; |
| 46 | |
iclelland | 8467f46 | 2015-10-21 14:03:13 | [diff] [blame] | 47 | #endif // CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_ |