| 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 "content/browser/android/background_sync_launcher_android.h" | 5 #include "content/browser/android/background_sync_launcher_android.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "jni/BackgroundSyncLauncher_jni.h" | 8 #include "jni/BackgroundSyncLauncher_jni.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 if (launch_when_next_online) | 40 if (launch_when_next_online) |
| 41 launch_when_next_online_registrants_.insert(registrant); | 41 launch_when_next_online_registrants_.insert(registrant); |
| 42 else | 42 else |
| 43 launch_when_next_online_registrants_.erase(registrant); | 43 launch_when_next_online_registrants_.erase(registrant); |
| 44 | 44 |
| 45 bool now_launching = !launch_when_next_online_registrants_.empty(); | 45 bool now_launching = !launch_when_next_online_registrants_.empty(); |
| 46 if (was_launching != now_launching) { | 46 if (was_launching != now_launching) { |
| 47 JNIEnv* env = base::android::AttachCurrentThread(); | 47 JNIEnv* env = base::android::AttachCurrentThread(); |
| 48 Java_BackgroundSyncLauncher_setLaunchWhenNextOnline( | 48 Java_BackgroundSyncLauncher_setLaunchWhenNextOnline( |
| 49 env, java_launcher_.obj(), now_launching); | 49 env, java_launcher_.obj(), base::android::GetApplicationContext(), |
| 50 now_launching); |
| 50 } | 51 } |
| 51 } | 52 } |
| 52 | 53 |
| 53 // static | 54 // static |
| 54 bool BackgroundSyncLauncherAndroid::RegisterLauncher(JNIEnv* env) { | 55 bool BackgroundSyncLauncherAndroid::RegisterLauncher(JNIEnv* env) { |
| 55 return RegisterNativesImpl(env); | 56 return RegisterNativesImpl(env); |
| 56 } | 57 } |
| 57 | 58 |
| 58 BackgroundSyncLauncherAndroid::BackgroundSyncLauncherAndroid() { | 59 BackgroundSyncLauncherAndroid::BackgroundSyncLauncherAndroid() { |
| 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 60 | 61 |
| 61 JNIEnv* env = base::android::AttachCurrentThread(); | 62 JNIEnv* env = base::android::AttachCurrentThread(); |
| 62 java_launcher_.Reset(Java_BackgroundSyncLauncher_create( | 63 java_launcher_.Reset(Java_BackgroundSyncLauncher_create( |
| 63 env, base::android::GetApplicationContext())); | 64 env, base::android::GetApplicationContext())); |
| 64 } | 65 } |
| 65 | 66 |
| 66 BackgroundSyncLauncherAndroid::~BackgroundSyncLauncherAndroid() { | 67 BackgroundSyncLauncherAndroid::~BackgroundSyncLauncherAndroid() { |
| 67 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 68 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 68 | 69 |
| 69 JNIEnv* env = base::android::AttachCurrentThread(); | 70 JNIEnv* env = base::android::AttachCurrentThread(); |
| 70 Java_BackgroundSyncLauncher_destroy(env, java_launcher_.obj()); | 71 Java_BackgroundSyncLauncher_destroy(env, java_launcher_.obj()); |
| 71 } | 72 } |
| 72 | 73 |
| 73 } // namespace content | 74 } // namespace content |
| OLD | NEW |