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

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

Issue 1358163004: [Android] Introduce RegistrationPolicy for NetworkChangeNotifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile of tests Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/android/java/src/org/chromium/net/NetworkChangeNotifier.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.os.Process; 10 import android.os.Process;
11 11
12 import org.chromium.base.ThreadUtils; 12 import org.chromium.base.ThreadUtils;
13 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 14 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.base.annotations.NativeClassQualifiedName; 15 import org.chromium.base.annotations.NativeClassQualifiedName;
16 import org.chromium.net.NetworkChangeNotifierAutoDetect; 16 import org.chromium.net.NetworkChangeNotifierAutoDetect;
17 import org.chromium.net.RegistrationPolicyAlwaysRegister;
17 18
18 import java.util.ArrayList; 19 import java.util.ArrayList;
19 import java.util.List; 20 import java.util.List;
20 21
21 /** 22 /**
22 * Contains the Java code used by the BackgroundSyncNetworkObserverAndroid C++ c lass. 23 * Contains the Java code used by the BackgroundSyncNetworkObserverAndroid C++ c lass.
23 * 24 *
24 * The purpose of this class is to listen for and forward network connectivity e vents to the 25 * The purpose of this class is to listen for and forward network connectivity e vents to the
25 * BackgroundSyncNetworkObserverAndroid objects even when the application is pau sed. The standard 26 * BackgroundSyncNetworkObserverAndroid objects even when the application is pau sed. The standard
26 * NetworkChangeNotifier does not listen for connectivity events when the applic ation is paused. 27 * NetworkChangeNotifier does not listen for connectivity events when the applic ation is paused.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 67 }
67 68
68 private void registerObserver(final long nativePtr) { 69 private void registerObserver(final long nativePtr) {
69 ThreadUtils.assertOnUiThread(); 70 ThreadUtils.assertOnUiThread();
70 if (!canCreateObserver(mContext)) { 71 if (!canCreateObserver(mContext)) {
71 return; 72 return;
72 } 73 }
73 74
74 // Create the NetworkChangeNotifierAutoDetect if it does not exist alrea dy. 75 // Create the NetworkChangeNotifierAutoDetect if it does not exist alrea dy.
75 if (mNotifier == null) { 76 if (mNotifier == null) {
76 mNotifier = 77 mNotifier = new NetworkChangeNotifierAutoDetect(this, mContext,
77 new NetworkChangeNotifierAutoDetect(this, mContext, true /* always listen */); 78 new RegistrationPolicyAlwaysRegister());
78 } 79 }
79 mNativePtrs.add(nativePtr); 80 mNativePtrs.add(nativePtr);
80 81
81 nativeNotifyConnectionTypeChanged( 82 nativeNotifyConnectionTypeChanged(
82 nativePtr, mNotifier.getCurrentConnectionType(mNotifier.getCurre ntNetworkState())); 83 nativePtr, mNotifier.getCurrentConnectionType(mNotifier.getCurre ntNetworkState()));
83 } 84 }
84 85
85 @CalledByNative 86 @CalledByNative
86 private void removeObserver(long nativePtr) { 87 private void removeObserver(long nativePtr) {
87 ThreadUtils.assertOnUiThread(); 88 ThreadUtils.assertOnUiThread();
(...skipping 20 matching lines...) Expand all
108 @Override 109 @Override
109 public void onNetworkSoonToDisconnect(int netId) {} 110 public void onNetworkSoonToDisconnect(int netId) {}
110 @Override 111 @Override
111 public void onNetworkDisconnect(int netId) {} 112 public void onNetworkDisconnect(int netId) {}
112 @Override 113 @Override
113 public void updateActiveNetworkList(int[] activeNetIds) {} 114 public void updateActiveNetworkList(int[] activeNetIds) {}
114 115
115 @NativeClassQualifiedName("BackgroundSyncNetworkObserverAndroid::Observer") 116 @NativeClassQualifiedName("BackgroundSyncNetworkObserverAndroid::Observer")
116 private native void nativeNotifyConnectionTypeChanged(long nativePtr, int ne wConnectionType); 117 private native void nativeNotifyConnectionTypeChanged(long nativePtr, int ne wConnectionType);
117 } 118 }
OLDNEW
« no previous file with comments | « no previous file | net/android/java/src/org/chromium/net/NetworkChangeNotifier.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698