OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" | 5 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" |
6 | 6 |
7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "jni/SnippetsLauncher_jni.h" | 9 #include "jni/SnippetsLauncher_jni.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 return g_snippets_launcher.Pointer(); | 23 return g_snippets_launcher.Pointer(); |
24 } | 24 } |
25 | 25 |
26 // static | 26 // static |
27 bool NTPSnippetsLauncher::Register(JNIEnv* env) { | 27 bool NTPSnippetsLauncher::Register(JNIEnv* env) { |
28 return RegisterNativesImpl(env); | 28 return RegisterNativesImpl(env); |
29 } | 29 } |
30 | 30 |
31 bool NTPSnippetsLauncher::Schedule(base::TimeDelta period_wifi_charging, | 31 bool NTPSnippetsLauncher::Schedule(base::TimeDelta period_wifi_charging, |
32 base::TimeDelta period_wifi, | 32 base::TimeDelta period_wifi, |
33 base::TimeDelta period_fallback) { | 33 base::TimeDelta period_fallback, |
| 34 base::Time reschedule_time) { |
34 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 35 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
35 | 36 |
36 JNIEnv* env = base::android::AttachCurrentThread(); | 37 JNIEnv* env = base::android::AttachCurrentThread(); |
37 return Java_SnippetsLauncher_schedule( | 38 return Java_SnippetsLauncher_schedule( |
38 env, java_launcher_.obj(), period_wifi_charging.InSeconds(), | 39 env, java_launcher_.obj(), period_wifi_charging.InSeconds(), |
39 period_wifi.InSeconds(), period_fallback.InSeconds()); | 40 period_wifi.InSeconds(), period_fallback.InSeconds(), |
| 41 reschedule_time.ToJavaTime()); |
40 } | 42 } |
41 | 43 |
42 bool NTPSnippetsLauncher::Unschedule() { | 44 bool NTPSnippetsLauncher::Unschedule() { |
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 45 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
44 | 46 |
45 JNIEnv* env = base::android::AttachCurrentThread(); | 47 JNIEnv* env = base::android::AttachCurrentThread(); |
46 return Java_SnippetsLauncher_unschedule(env, java_launcher_.obj()); | 48 return Java_SnippetsLauncher_unschedule(env, java_launcher_.obj()); |
47 } | 49 } |
48 | 50 |
49 NTPSnippetsLauncher::NTPSnippetsLauncher() { | 51 NTPSnippetsLauncher::NTPSnippetsLauncher() { |
50 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 52 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
51 | 53 |
52 JNIEnv* env = base::android::AttachCurrentThread(); | 54 JNIEnv* env = base::android::AttachCurrentThread(); |
53 java_launcher_.Reset(Java_SnippetsLauncher_create( | 55 java_launcher_.Reset(Java_SnippetsLauncher_create( |
54 env, base::android::GetApplicationContext())); | 56 env, base::android::GetApplicationContext())); |
55 } | 57 } |
56 | 58 |
57 NTPSnippetsLauncher::~NTPSnippetsLauncher() { | 59 NTPSnippetsLauncher::~NTPSnippetsLauncher() { |
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
59 | 61 |
60 JNIEnv* env = base::android::AttachCurrentThread(); | 62 JNIEnv* env = base::android::AttachCurrentThread(); |
61 Java_SnippetsLauncher_destroy(env, java_launcher_.obj()); | 63 Java_SnippetsLauncher_destroy(env, java_launcher_.obj()); |
62 java_launcher_.Reset(); | 64 java_launcher_.Reset(); |
63 } | 65 } |
OLD | NEW |