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

Side by Side Diff: chrome/browser/android/ntp_snippets_launcher.cc

Issue 1699143002: [NTP Snippets] Schedule periodic fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snippets_feature
Patch Set: fix bots Created 4 years, 10 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 2016 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 #include "chrome/browser/android/ntp_snippets_launcher.h"
6
7 #include "base/android/context_utils.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "jni/SnippetsLauncher_jni.h"
10
11 using content::BrowserThread;
12
13 namespace {
14
15 base::LazyInstance<NTPSnippetsLauncher> g_snippets_launcher =
16 LAZY_INSTANCE_INITIALIZER;
17
18 } // namespace
19
20 // static
21 NTPSnippetsLauncher* NTPSnippetsLauncher::Get() {
22 DCHECK_CURRENTLY_ON(BrowserThread::UI);
23 return g_snippets_launcher.Pointer();
24 }
25
26 // static
27 bool NTPSnippetsLauncher::Register(JNIEnv* env) {
28 return RegisterNativesImpl(env);
29 }
30
31 bool NTPSnippetsLauncher::Schedule(int period_seconds) {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33
34 JNIEnv* env = base::android::AttachCurrentThread();
35 return Java_SnippetsLauncher_schedule(
36 env, java_launcher_.obj(), period_seconds);
37 }
38
39 bool NTPSnippetsLauncher::Unschedule() {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41
42 JNIEnv* env = base::android::AttachCurrentThread();
43 return Java_SnippetsLauncher_unschedule(env, java_launcher_.obj());
44 }
45
46 NTPSnippetsLauncher::NTPSnippetsLauncher() {
47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
48
49 JNIEnv* env = base::android::AttachCurrentThread();
50 java_launcher_.Reset(Java_SnippetsLauncher_create(
51 env, base::android::GetApplicationContext()));
52 }
53
54 NTPSnippetsLauncher::~NTPSnippetsLauncher() {
55 DCHECK_CURRENTLY_ON(BrowserThread::UI);
56
57 JNIEnv* env = base::android::AttachCurrentThread();
58 Java_SnippetsLauncher_destroy(env, java_launcher_.obj());
59 java_launcher_.Reset();
60 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp_snippets_launcher.h ('k') | chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698