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 is backed by a NetworkChangeNotifier |
| 16 // that listens for network events even when the browser is paused, unlike the |
| 17 // standard NetworkChangeNotifier. This ensures that sync events can be fired |
| 18 // even when the browser is backgrounded, and other network observers are |
| 19 // disabled. |
| 20 class BackgroundSyncNetworkObserverAndroid |
| 21 : public BackgroundSyncNetworkObserver { |
| 22 public: |
| 23 // Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is |
| 24 // called via PostMessage when the network connection changes. |
| 25 BackgroundSyncNetworkObserverAndroid( |
| 26 const base::Closure& network_changed_callback); |
| 27 |
| 28 ~BackgroundSyncNetworkObserverAndroid() override; |
| 29 |
| 30 static bool RegisterNetworkObserver(JNIEnv* env); |
| 31 |
| 32 // Called from BackgroundSyncNetworkObserver.java on the JNI thread whenever |
| 33 // the connection type changes. This updates the current connection type seen |
| 34 // by this class and calls the |network_changed_callback| provided to the |
| 35 // constructor. |
| 36 void NotifyConnectionTypeChanged(JNIEnv* env, |
| 37 jobject jcaller, |
| 38 jint new_connection_type); |
| 39 |
| 40 private: |
| 41 base::android::ScopedJavaLocalRef<jobject> observer_; |
| 42 }; |
| 43 |
| 44 } // namespace content |
| 45 |
| 46 #endif // CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_ |
OLD | NEW |