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