| 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..69b17f08ad1e848a11b893e6dfaa1ad17e9a7ddd
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/BackgroundSyncNetworkObserver.java
|
| @@ -0,0 +1,52 @@
|
| +// 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.
|
| + *
|
| + * The purpose of this class is to listen for and forward network connectivity events to the
|
| + * BackgroundSyncNetworkObserverAndroid even when the application is paused. The standard
|
| + * NetworkChangeNotifier does not listen for connectivity events when the application is paused.
|
| + *
|
| + * This class should live on the main thread.
|
| + */
|
| +@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::Observer")
|
| + private native void nativeNotifyConnectionTypeChanged(long nativePtr, int newConnectionType);
|
| +}
|
|
|