OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/background_sync_launcher_android.h" | 5 #include "chrome/browser/android/background_sync_launcher_android.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/BackgroundSyncLauncher_jni.h" | 9 #include "jni/BackgroundSyncLauncher_jni.h" |
9 | 10 |
10 using content::BrowserThread; | 11 using content::BrowserThread; |
11 | 12 |
12 namespace { | 13 namespace { |
13 base::LazyInstance<BackgroundSyncLauncherAndroid>::DestructorAtExit | 14 base::LazyInstance<BackgroundSyncLauncherAndroid>::DestructorAtExit |
14 g_background_sync_launcher = LAZY_INSTANCE_INITIALIZER; | 15 g_background_sync_launcher = LAZY_INSTANCE_INITIALIZER; |
15 | 16 |
16 // Disables the Play Services version check for testing on Chromium build bots. | 17 // Disables the Play Services version check for testing on Chromium build bots. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 disable_play_services_version_check_for_tests = disabled; | 54 disable_play_services_version_check_for_tests = disabled; |
54 } | 55 } |
55 | 56 |
56 // static | 57 // static |
57 bool BackgroundSyncLauncherAndroid::ShouldDisableBackgroundSync() { | 58 bool BackgroundSyncLauncherAndroid::ShouldDisableBackgroundSync() { |
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
59 if (disable_play_services_version_check_for_tests) { | 60 if (disable_play_services_version_check_for_tests) { |
60 return false; | 61 return false; |
61 } | 62 } |
62 return Java_BackgroundSyncLauncher_shouldDisableBackgroundSync( | 63 return Java_BackgroundSyncLauncher_shouldDisableBackgroundSync( |
63 base::android::AttachCurrentThread()); | 64 base::android::AttachCurrentThread(), |
| 65 base::android::GetApplicationContext()); |
64 } | 66 } |
65 | 67 |
66 BackgroundSyncLauncherAndroid::BackgroundSyncLauncherAndroid() { | 68 BackgroundSyncLauncherAndroid::BackgroundSyncLauncherAndroid() { |
67 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 69 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
68 | 70 |
69 JNIEnv* env = base::android::AttachCurrentThread(); | 71 JNIEnv* env = base::android::AttachCurrentThread(); |
70 java_launcher_.Reset(Java_BackgroundSyncLauncher_create(env)); | 72 java_launcher_.Reset(Java_BackgroundSyncLauncher_create( |
| 73 env, base::android::GetApplicationContext())); |
71 } | 74 } |
72 | 75 |
73 BackgroundSyncLauncherAndroid::~BackgroundSyncLauncherAndroid() { | 76 BackgroundSyncLauncherAndroid::~BackgroundSyncLauncherAndroid() { |
74 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
75 | 78 |
76 JNIEnv* env = base::android::AttachCurrentThread(); | 79 JNIEnv* env = base::android::AttachCurrentThread(); |
77 Java_BackgroundSyncLauncher_destroy(env, java_launcher_); | 80 Java_BackgroundSyncLauncher_destroy(env, java_launcher_); |
78 } | 81 } |
OLD | NEW |