OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_ | |
6 #define CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_ | |
7 | |
8 #include "base/android/jni_android.h" | |
9 #include "base/android/scoped_java_ref.h" | |
10 #include "content/browser/background_sync/background_sync_network_observer.h" | |
11 | |
12 namespace content { | |
13 | |
14 // BackgroundSyncNetworkObserverAndroid is a specialized | |
15 // BackgroundSyncNetworkObserver which always uses the actual connectivity state | |
jkarlin
2015/08/28 01:19:48
"always uses the actual connectivity state" sounds
iclelland
2015/08/31 16:00:52
Done.
| |
16 // of the device to determine whether sync events are eligible to be fired. This | |
17 // ensures that sync events can be fired even when the browser is backgrounded, | |
18 // and other network observers are disabled. | |
19 class BackgroundSyncNetworkObserverAndroid | |
20 : public BackgroundSyncNetworkObserver { | |
21 public: | |
22 // Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is | |
23 // called when the network connection changes asynchronously via PostMessage. | |
jkarlin
2015/08/28 01:19:48
can probably remove 'asynchronously' without losin
iclelland
2015/08/31 16:00:52
Done.
| |
24 BackgroundSyncNetworkObserverAndroid( | |
25 const base::Closure& network_changed_callback); | |
26 | |
27 ~BackgroundSyncNetworkObserverAndroid() override; | |
28 | |
29 static bool RegisterNetworkObserver(JNIEnv* env); | |
30 | |
31 // Called from BackgroundSyncNetworkObserver.java on the JNI thread whenever | |
32 // the connection type changes. This updates the current connection type seen | |
33 // by this class and calls the |network_changed_callback|. | |
jkarlin
2015/08/28 01:19:48
calls |network_changed_callback| provided to the c
iclelland
2015/08/31 16:00:52
Done.
| |
34 void NotifyConnectionTypeChanged(JNIEnv* env, | |
35 jobject jcaller, | |
36 jint new_connection_type); | |
37 | |
38 private: | |
39 base::android::ScopedJavaLocalRef<jobject> observer_; | |
40 }; | |
41 | |
42 } // namespace content | |
43 | |
44 #endif // CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_ | |
OLD | NEW |