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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/BackgroundSyncNetworkObserver.java

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/public/android/java/src/org/chromium/content/browser/BackgroundSyncNetworkObserver.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/BackgroundSyncNetworkObserver.java b/content/public/android/java/src/org/chromium/content/browser/BackgroundSyncNetworkObserver.java
new file mode 100644
index 0000000000000000000000000000000000000000..2ee8c4969e681ec2c376eb00ee32728db023d97d
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/BackgroundSyncNetworkObserver.java
@@ -0,0 +1,50 @@
+// 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.
+
+package org.chromium.content.browser;
+
+import android.content.Context;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.base.annotations.NativeClassQualifiedName;
+import org.chromium.net.NetworkChangeNotifierAutoDetect;
+
+/**
+ * Contains the Java code used by the BackgroundSyncNetworkObserverAndroid C++ class.
+ *
+ * Its purpose is to allow the BackgroundSyncManager to determine whether or not the device is
+ * actually online, for the purpose of triggering background sync events, without having to trigger
jkarlin 2015/08/28 01:19:48 remove "actually". The last bit doesn't make much
iclelland 2015/08/31 16:00:52 Done.
+ * an online event while Chrome is backgrounded.
+ */
+@JNINamespace("content")
+public class BackgroundSyncNetworkObserver implements NetworkChangeNotifierAutoDetect.Observer {
+
+ private NetworkChangeNotifierAutoDetect mNotifier;
+ private long mNativePtr;
+
+ public BackgroundSyncNetworkObserver(Context ctx, long nativePtr) {
+ mNotifier = new NetworkChangeNotifierAutoDetect(this, ctx, true);
+ mNativePtr = nativePtr;
+ onConnectionTypeChanged(mNotifier.getCurrentConnectionType(
+ mNotifier.getCurrentNetworkState()));
+ }
+
+ @CalledByNative
+ public static BackgroundSyncNetworkObserver createObserver(Context ctx, long nativePtr) {
+ return new BackgroundSyncNetworkObserver(ctx, nativePtr);
+ }
+
+ @Override
+ public void onConnectionTypeChanged(int newConnectionType) {
+ nativeNotifyConnectionTypeChanged(mNativePtr, newConnectionType);
+ }
+
+ @Override
+ public void onMaxBandwidthChanged(double maxBandwidthMbps) {
+ }
+
+ @NativeClassQualifiedName("BackgroundSyncNetworkObserverAndroid")
+ private native void nativeNotifyConnectionTypeChanged(long nativePtr, int newConnectionType);
+}

Powered by Google App Engine
This is Rietveld 408576698