blob: 8afb0bf7669b5cfd48564f424c8b48a29298b650 [file] [log] [blame]
jkarlindb185222015-05-29 12:02:001// 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
iclelland8467f462015-10-21 14:03:135#ifndef CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_
6#define CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_
jkarlindb185222015-05-29 12:02:007
avie4d7b6f2015-12-26 00:59:188#include <stdint.h>
9
jkarlindb185222015-05-29 12:02:0010#include <set>
11
12#include "base/android/jni_android.h"
13#include "base/lazy_instance.h"
14#include "base/macros.h"
jkarlindb185222015-05-29 12:02:0015
16namespace content {
17
18class BackgroundSyncManager;
19
iclelland8467f462015-10-21 14:03:1320}
21
jkarlindb185222015-05-29 12:02:0022// 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.
iclelland8467f462015-10-21 14:03:1326class BackgroundSyncLauncherAndroid {
jkarlindb185222015-05-29 12:02:0027 public:
28 static BackgroundSyncLauncherAndroid* Get();
29
jkarlin4302d712015-11-10 10:59:0130 static void LaunchBrowserIfStopped(bool launch_when_next_online,
31 int64_t min_delay_ms);
jkarlindb185222015-05-29 12:02:0032
33 static bool RegisterLauncher(JNIEnv* env);
34
iclellandd054a6f2016-01-11 20:16:1435 static bool ShouldDisableBackgroundSync();
36
37 // TODO(iclelland): Remove this once the bots have their play services package
38 // updated before every test run. (https://crbug.com/514449)
39 static void SetPlayServicesVersionCheckDisabledForTests(bool disabled);
40
jkarlindb185222015-05-29 12:02:0041 private:
42 friend struct base::DefaultLazyInstanceTraits<BackgroundSyncLauncherAndroid>;
43
44 // Constructor and destructor marked private to enforce singleton
45 BackgroundSyncLauncherAndroid();
46 ~BackgroundSyncLauncherAndroid();
47
jkarlin4302d712015-11-10 10:59:0148 void LaunchBrowserIfStoppedImpl(bool launch_when_next_online,
49 int64_t min_delay_ms);
jkarlindb185222015-05-29 12:02:0050
jkarlindb185222015-05-29 12:02:0051 base::android::ScopedJavaGlobalRef<jobject> java_launcher_;
52 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncLauncherAndroid);
53};
54
iclelland8467f462015-10-21 14:03:1355#endif // CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_