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 "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
8 #include "jni/SnippetsLauncher_jni.h" | 9 #include "jni/SnippetsLauncher_jni.h" |
9 | 10 |
10 using content::BrowserThread; | 11 using content::BrowserThread; |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 base::LazyInstance<NTPSnippetsLauncher>::DestructorAtExit g_snippets_launcher = | 15 base::LazyInstance<NTPSnippetsLauncher>::DestructorAtExit g_snippets_launcher = |
15 LAZY_INSTANCE_INITIALIZER; | 16 LAZY_INSTANCE_INITIALIZER; |
16 | 17 |
(...skipping 19 matching lines...) Expand all Loading... |
36 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 37 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
37 | 38 |
38 JNIEnv* env = base::android::AttachCurrentThread(); | 39 JNIEnv* env = base::android::AttachCurrentThread(); |
39 return Java_SnippetsLauncher_unschedule(env, java_launcher_); | 40 return Java_SnippetsLauncher_unschedule(env, java_launcher_); |
40 } | 41 } |
41 | 42 |
42 NTPSnippetsLauncher::NTPSnippetsLauncher() { | 43 NTPSnippetsLauncher::NTPSnippetsLauncher() { |
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
44 | 45 |
45 JNIEnv* env = base::android::AttachCurrentThread(); | 46 JNIEnv* env = base::android::AttachCurrentThread(); |
46 java_launcher_.Reset(Java_SnippetsLauncher_create(env)); | 47 java_launcher_.Reset(Java_SnippetsLauncher_create( |
| 48 env, base::android::GetApplicationContext())); |
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_SnippetsLauncher_destroy(env, java_launcher_); | 55 Java_SnippetsLauncher_destroy(env, java_launcher_); |
54 java_launcher_.Reset(); | 56 java_launcher_.Reset(); |
55 } | 57 } |
OLD | NEW |