Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: content/browser/android/background_sync_network_observer_android.h

Issue 1294603003: [BackgroundSync] Trigger Background Sync events when Chrome is backgrounded on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move BackgroundSyncNetworkObserverAndroid destructor to satisfy the compiler Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/background_sync_network_observer_android.h
diff --git a/content/browser/android/background_sync_network_observer_android.h b/content/browser/android/background_sync_network_observer_android.h
new file mode 100644
index 0000000000000000000000000000000000000000..7785b2a3c97783ea9b4cfa8b2fbcb573b452db71
--- /dev/null
+++ b/content/browser/android/background_sync_network_observer_android.h
@@ -0,0 +1,44 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_
+#define CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_
+
+#include "base/android/jni_android.h"
+#include "base/android/scoped_java_ref.h"
+#include "content/browser/background_sync/background_sync_network_observer.h"
+
+namespace content {
+
+// BackgroundSyncNetworkObserverAndroid is a specialized
+// 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.
+// of the device to determine whether sync events are eligible to be fired. This
+// ensures that sync events can be fired even when the browser is backgrounded,
+// and other network observers are disabled.
+class BackgroundSyncNetworkObserverAndroid
+ : public BackgroundSyncNetworkObserver {
+ public:
+ // Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is
+ // 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.
+ BackgroundSyncNetworkObserverAndroid(
+ const base::Closure& network_changed_callback);
+
+ ~BackgroundSyncNetworkObserverAndroid() override;
+
+ static bool RegisterNetworkObserver(JNIEnv* env);
+
+ // Called from BackgroundSyncNetworkObserver.java on the JNI thread whenever
+ // the connection type changes. This updates the current connection type seen
+ // 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.
+ void NotifyConnectionTypeChanged(JNIEnv* env,
+ jobject jcaller,
+ jint new_connection_type);
+
+ private:
+ base::android::ScopedJavaLocalRef<jobject> observer_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_BACKGROUND_SYNC_NETWORK_OBSERVER_ANDROID_H_

Powered by Google App Engine
This is Rietveld 408576698