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