Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: chrome/browser/android/offline_pages/prefetch/prefetch_background_task.h

Issue 2820263002: [Offline Prefetch] Create a new JobScheduler task to wake up for net activity. (Closed)
Patch Set: Remove the "Is Scheduled" check because it's not supported by BackgroundTaskScheduler. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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
5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PREFETCH_PREFETCH_BACKGROUND_TASK_H _
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PREFETCH_PREFETCH_BACKGROUND_TASK_H _
7
8 #include "base/android/jni_android.h"
9 #include "components/offline_pages/core/prefetch/prefetch_service.h"
10
11 namespace offline_pages {
12
13 // A task with a counterpart in Java for managing the background activity of the
14 // offline page prefetcher. Schedules and listens for events about prefetching
15 // tasks.
16 class PrefetchBackgroundTask : public PrefetchService::ScopedBackgroundTask {
carlosk 2017/04/19 23:01:38 Why is this out of the offline_pages::prefetch nam
dewittj 2017/04/20 21:41:45 I invented the offline_pages::prefetch namespace o
17 public:
18 PrefetchBackgroundTask(
19 JNIEnv* env,
20 const base::android::JavaParamRef<jobject>& j_prefetch_background_task,
21 PrefetchService* service);
22 ~PrefetchBackgroundTask() override;
23
24 // API for interacting with JobScheduler from native.
25 // Schedules the default 'NWake' prefetching task. Does nothing if
26 // JobScheduler is not supported.
27 static void Schedule();
28
29 // Cancels the default 'NWake' prefetching task. Does nothing if
30 // JobScheduler is not supported.
31 static void Cancel();
32
33 // Java hooks.
34 bool OnStopTask(JNIEnv* env,
35 const base::android::JavaParamRef<jobject>& jcaller);
36
37 // When this task completes, we tell the system whether the task should be
38 // rescheduled with the same parameters as last time.
39 void SetNeedsReschedule(bool reschedule) override;
40 bool needs_reschedule() { return needs_reschedule_; }
41
42 private:
43 bool needs_reschedule_ = true;
44
45 // A pointer to the controlling |PrefetchBackgroundTask|.
46 base::android::ScopedJavaGlobalRef<jobject> java_prefetch_background_task_;
47
48 // The PrefetchService owns |this|, so a raw pointer is OK.
49 PrefetchService* service_;
50 };
51
52 bool RegisterPrefetchBackgroundTask(JNIEnv* env);
53
54 } // namespace offline_pages
55
56 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PREFETCH_PREFETCH_BACKGROUND_TAS K_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698