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 |
11 using content::BrowserThread; | 11 using content::BrowserThread; |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 base::LazyInstance<NTPSnippetsLauncher> g_snippets_launcher = | 15 base::LazyInstance<NTPSnippetsLauncher> g_snippets_launcher = |
16 LAZY_INSTANCE_INITIALIZER; | 16 LAZY_INSTANCE_INITIALIZER; |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 // static | 20 // static |
21 NTPSnippetsLauncher* NTPSnippetsLauncher::Get() { | 21 NTPSnippetsLauncher* NTPSnippetsLauncher::Get() { |
22 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 22 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
23 return g_snippets_launcher.Pointer(); | 23 return g_snippets_launcher.Pointer(); |
24 } | 24 } |
25 | 25 |
26 // static | |
27 bool NTPSnippetsLauncher::Register(JNIEnv* env) { | |
28 return RegisterNativesImpl(env); | |
29 } | |
30 | |
31 bool NTPSnippetsLauncher::Schedule(base::TimeDelta period_wifi_charging, | 26 bool NTPSnippetsLauncher::Schedule(base::TimeDelta period_wifi_charging, |
32 base::TimeDelta period_wifi, | 27 base::TimeDelta period_wifi, |
33 base::TimeDelta period_fallback, | 28 base::TimeDelta period_fallback, |
34 base::Time reschedule_time) { | 29 base::Time reschedule_time) { |
35 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
36 | 31 |
37 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
38 return Java_SnippetsLauncher_schedule( | 33 return Java_SnippetsLauncher_schedule( |
39 env, java_launcher_.obj(), period_wifi_charging.InSeconds(), | 34 env, java_launcher_.obj(), period_wifi_charging.InSeconds(), |
40 period_wifi.InSeconds(), period_fallback.InSeconds(), | 35 period_wifi.InSeconds(), period_fallback.InSeconds(), |
(...skipping 15 matching lines...) Expand all Loading... |
56 env, base::android::GetApplicationContext())); | 51 env, base::android::GetApplicationContext())); |
57 } | 52 } |
58 | 53 |
59 NTPSnippetsLauncher::~NTPSnippetsLauncher() { | 54 NTPSnippetsLauncher::~NTPSnippetsLauncher() { |
60 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
61 | 56 |
62 JNIEnv* env = base::android::AttachCurrentThread(); | 57 JNIEnv* env = base::android::AttachCurrentThread(); |
63 Java_SnippetsLauncher_destroy(env, java_launcher_.obj()); | 58 Java_SnippetsLauncher_destroy(env, java_launcher_.obj()); |
64 java_launcher_.Reset(); | 59 java_launcher_.Reset(); |
65 } | 60 } |
OLD | NEW |