Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 network_handle_by_address_.clear(); | 233 network_handle_by_address_.clear(); |
| 234 network_info_by_handle_.clear(); | 234 network_info_by_handle_.clear(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 // The implementation is largely taken from UDPSocketPosix::BindToNetwork in | 237 // The implementation is largely taken from UDPSocketPosix::BindToNetwork in |
| 238 // https://cs.chromium.org/chromium/src/net/udp/udp_socket_posix.cc | 238 // https://cs.chromium.org/chromium/src/net/udp/udp_socket_posix.cc |
| 239 rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork( | 239 rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork( |
| 240 int socket_fd, | 240 int socket_fd, |
| 241 const rtc::IPAddress& address) { | 241 const rtc::IPAddress& address) { |
| 242 RTC_CHECK(thread_checker_.CalledOnValidThread()); | 242 RTC_CHECK(thread_checker_.CalledOnValidThread()); |
| 243 | |
| 244 jmethodID network_binding_supported_id = GetMethodID( | |
| 245 jni(), *j_network_monitor_class_, "networkBindingSupported", "()Z"); | |
| 243 // Android prior to Lollipop didn't have support for binding sockets to | 246 // Android prior to Lollipop didn't have support for binding sockets to |
| 244 // networks. In that case it should not have reached here because | 247 // networks. This may also occur if there is no connectivity manager service. |
| 245 // |network_handle_by_address_| is only populated in Android Lollipop | 248 if (!jni()->CallBooleanMethod(*j_network_monitor_, |
|
magjed_webrtc
2017/02/15 12:27:26
Maybe you should add a CHECK_EXCEPTION(jni()) afte
Taylor Brandstetter
2017/02/15 18:32:24
Done.
| |
| 246 // and above. | 249 network_binding_supported_id)) { |
| 247 if (android_sdk_int_ < SDK_VERSION_LOLLIPOP) { | 250 LOG(LS_WARNING) << "BindSocketToNetwork is not supported on this platform " |
| 248 LOG(LS_ERROR) << "BindSocketToNetwork is not supported in Android SDK " | 251 << "(Android SDK: " << android_sdk_int_ << ")"; |
| 249 << android_sdk_int_; | |
| 250 return rtc::NetworkBindingResult::NOT_IMPLEMENTED; | 252 return rtc::NetworkBindingResult::NOT_IMPLEMENTED; |
| 251 } | 253 } |
| 252 | 254 |
| 253 auto iter = network_handle_by_address_.find(address); | 255 auto iter = network_handle_by_address_.find(address); |
| 254 if (iter == network_handle_by_address_.end()) { | 256 if (iter == network_handle_by_address_.end()) { |
| 255 return rtc::NetworkBindingResult::ADDRESS_NOT_FOUND; | 257 return rtc::NetworkBindingResult::ADDRESS_NOT_FOUND; |
| 256 } | 258 } |
| 257 NetworkHandle network_handle = iter->second; | 259 NetworkHandle network_handle = iter->second; |
| 258 | 260 |
| 259 int rv = 0; | 261 int rv = 0; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)( | 429 JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)( |
| 428 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, | 430 JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, |
| 429 jlong network_handle) { | 431 jlong network_handle) { |
| 430 AndroidNetworkMonitor* network_monitor = | 432 AndroidNetworkMonitor* network_monitor = |
| 431 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); | 433 reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor); |
| 432 network_monitor->OnNetworkDisconnected( | 434 network_monitor->OnNetworkDisconnected( |
| 433 static_cast<NetworkHandle>(network_handle)); | 435 static_cast<NetworkHandle>(network_handle)); |
| 434 } | 436 } |
| 435 | 437 |
| 436 } // namespace webrtc_jni | 438 } // namespace webrtc_jni |
| OLD | NEW |