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 | |
| 16 | namespace content { |
| 17 | |
| 18 | class BackgroundSyncManager; |
| 19 | |
iclelland | 8467f46 | 2015-10-21 14:03:13 | [diff] [blame] | 20 | } |
| 21 | |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 22 | // The BackgroundSyncLauncherAndroid singleton owns the Java |
| 23 | // BackgroundSyncLauncher object and is used to register interest in starting |
| 24 | // the browser the next time the device goes online. This class runs on the UI |
| 25 | // thread. |
iclelland | 8467f46 | 2015-10-21 14:03:13 | [diff] [blame] | 26 | class BackgroundSyncLauncherAndroid { |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 27 | public: |
| 28 | static BackgroundSyncLauncherAndroid* Get(); |
| 29 | |
jkarlin | 4302d71 | 2015-11-10 10:59:01 | [diff] [blame] | 30 | static void LaunchBrowserIfStopped(bool launch_when_next_online, |
| 31 | int64_t min_delay_ms); |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 32 | |
| 33 | static bool RegisterLauncher(JNIEnv* env); |
| 34 | |
| 35 | private: |
| 36 | friend struct base::DefaultLazyInstanceTraits<BackgroundSyncLauncherAndroid>; |
| 37 | |
| 38 | // Constructor and destructor marked private to enforce singleton |
| 39 | BackgroundSyncLauncherAndroid(); |
| 40 | ~BackgroundSyncLauncherAndroid(); |
| 41 | |
jkarlin | 4302d71 | 2015-11-10 10:59:01 | [diff] [blame] | 42 | void LaunchBrowserIfStoppedImpl(bool launch_when_next_online, |
| 43 | int64_t min_delay_ms); |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 44 | |
jkarlin | db18522 | 2015-05-29 12:02:00 | [diff] [blame] | 45 | base::android::ScopedJavaGlobalRef<jobject> java_launcher_; |
| 46 | DISALLOW_COPY_AND_ASSIGN(BackgroundSyncLauncherAndroid); |
| 47 | }; |
| 48 | |
iclelland | 8467f46 | 2015-10-21 14:03:13 | [diff] [blame] | 49 | #endif // CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_ |