OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.net; | 5 package org.chromium.net; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.chromium.base.CalledByNative; | 9 import org.chromium.base.CalledByNative; |
10 import org.chromium.base.JNINamespace; | 10 import org.chromium.base.JNINamespace; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (shouldAutoDetect) { | 127 if (shouldAutoDetect) { |
128 if (mAutoDetector == null) { | 128 if (mAutoDetector == null) { |
129 mAutoDetector = new NetworkChangeNotifierAutoDetect( | 129 mAutoDetector = new NetworkChangeNotifierAutoDetect( |
130 new NetworkChangeNotifierAutoDetect.Observer() { | 130 new NetworkChangeNotifierAutoDetect.Observer() { |
131 @Override | 131 @Override |
132 public void onConnectionTypeChanged(int newConnectionTyp
e) { | 132 public void onConnectionTypeChanged(int newConnectionTyp
e) { |
133 updateCurrentConnectionType(newConnectionType); | 133 updateCurrentConnectionType(newConnectionType); |
134 } | 134 } |
135 }, | 135 }, |
136 mContext); | 136 mContext); |
137 mCurrentConnectionType = mAutoDetector.getCurrentConnectionType(
); | 137 updateCurrentConnectionType(mAutoDetector.getCurrentConnectionTy
pe()); |
138 } | 138 } |
139 } else { | 139 } else { |
140 destroyAutoDetector(); | 140 destroyAutoDetector(); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 /** | 144 /** |
145 * Updates the perceived network state when not auto-detecting changes to co
nnectivity. | 145 * Updates the perceived network state when not auto-detecting changes to co
nnectivity. |
146 * | 146 * |
147 * @param networkAvailable True if the NetworkChangeNotifier should perceive
a "connected" | 147 * @param networkAvailable True if the NetworkChangeNotifier should perceive
a "connected" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 /** | 210 /** |
211 * Checks if there currently is connectivity. | 211 * Checks if there currently is connectivity. |
212 */ | 212 */ |
213 public static boolean isOnline() { | 213 public static boolean isOnline() { |
214 int connectionType = getInstance().getCurrentConnectionType(); | 214 int connectionType = getInstance().getCurrentConnectionType(); |
215 return connectionType != CONNECTION_UNKNOWN && connectionType != CONNECT
ION_NONE; | 215 return connectionType != CONNECTION_UNKNOWN && connectionType != CONNECT
ION_NONE; |
216 } | 216 } |
217 } | 217 } |
OLD | NEW |