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(), base::android::GetApplicationContext(), | 49 env, java_launcher_.obj(), now_launching); |
50 now_launching); | |
51 } | 50 } |
52 } | 51 } |
53 | 52 |
54 // static | 53 // static |
55 bool BackgroundSyncLauncherAndroid::RegisterLauncher(JNIEnv* env) { | 54 bool BackgroundSyncLauncherAndroid::RegisterLauncher(JNIEnv* env) { |
56 return RegisterNativesImpl(env); | 55 return RegisterNativesImpl(env); |
57 } | 56 } |
58 | 57 |
59 BackgroundSyncLauncherAndroid::BackgroundSyncLauncherAndroid() { | 58 BackgroundSyncLauncherAndroid::BackgroundSyncLauncherAndroid() { |
60 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
61 | 60 |
62 JNIEnv* env = base::android::AttachCurrentThread(); | 61 JNIEnv* env = base::android::AttachCurrentThread(); |
63 java_launcher_.Reset(Java_BackgroundSyncLauncher_create( | 62 java_launcher_.Reset(Java_BackgroundSyncLauncher_create( |
64 env, base::android::GetApplicationContext())); | 63 env, base::android::GetApplicationContext())); |
65 } | 64 } |
66 | 65 |
67 BackgroundSyncLauncherAndroid::~BackgroundSyncLauncherAndroid() { | 66 BackgroundSyncLauncherAndroid::~BackgroundSyncLauncherAndroid() { |
68 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 67 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
69 | 68 |
70 JNIEnv* env = base::android::AttachCurrentThread(); | 69 JNIEnv* env = base::android::AttachCurrentThread(); |
71 Java_BackgroundSyncLauncher_destroy(env, java_launcher_.obj()); | 70 Java_BackgroundSyncLauncher_destroy(env, java_launcher_.obj()); |
72 } | 71 } |
73 | 72 |
74 } // namespace content | 73 } // namespace content |
OLD | NEW |