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 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 bool NTPSnippetsLauncher::Schedule(base::TimeDelta period_wifi_charging, | 26 bool NTPSnippetsLauncher::Schedule(base::TimeDelta period_wifi_charging, |
27 base::TimeDelta period_wifi, | 27 base::TimeDelta period_wifi, |
28 base::TimeDelta period_fallback, | 28 base::TimeDelta period_fallback, |
29 base::Time reschedule_time) { | 29 base::Time reschedule_time) { |
30 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
31 | 31 |
32 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
33 return Java_SnippetsLauncher_schedule( | 33 return Java_SnippetsLauncher_schedule( |
34 env, java_launcher_.obj(), period_wifi_charging.InSeconds(), | 34 env, java_launcher_, period_wifi_charging.InSeconds(), |
35 period_wifi.InSeconds(), period_fallback.InSeconds(), | 35 period_wifi.InSeconds(), period_fallback.InSeconds(), |
36 reschedule_time.ToJavaTime()); | 36 reschedule_time.ToJavaTime()); |
37 } | 37 } |
38 | 38 |
39 bool NTPSnippetsLauncher::Unschedule() { | 39 bool NTPSnippetsLauncher::Unschedule() { |
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 40 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
41 | 41 |
42 JNIEnv* env = base::android::AttachCurrentThread(); | 42 JNIEnv* env = base::android::AttachCurrentThread(); |
43 return Java_SnippetsLauncher_unschedule(env, java_launcher_.obj()); | 43 return Java_SnippetsLauncher_unschedule(env, java_launcher_); |
44 } | 44 } |
45 | 45 |
46 NTPSnippetsLauncher::NTPSnippetsLauncher() { | 46 NTPSnippetsLauncher::NTPSnippetsLauncher() { |
47 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 47 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
48 | 48 |
49 JNIEnv* env = base::android::AttachCurrentThread(); | 49 JNIEnv* env = base::android::AttachCurrentThread(); |
50 java_launcher_.Reset(Java_SnippetsLauncher_create( | 50 java_launcher_.Reset(Java_SnippetsLauncher_create( |
51 env, base::android::GetApplicationContext())); | 51 env, base::android::GetApplicationContext())); |
52 } | 52 } |
53 | 53 |
54 NTPSnippetsLauncher::~NTPSnippetsLauncher() { | 54 NTPSnippetsLauncher::~NTPSnippetsLauncher() { |
55 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
56 | 56 |
57 JNIEnv* env = base::android::AttachCurrentThread(); | 57 JNIEnv* env = base::android::AttachCurrentThread(); |
58 Java_SnippetsLauncher_destroy(env, java_launcher_.obj()); | 58 Java_SnippetsLauncher_destroy(env, java_launcher_); |
59 java_launcher_.Reset(); | 59 java_launcher_.Reset(); |
60 } | 60 } |
OLD | NEW |