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

Unified Diff: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java

Issue 1389553002: bluetooth: Detect and fix incorrect thread usage of BluetoothDispatcherHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK_CURRENTLY_ON(BrowserThread::UI); 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/bluetooth/bluetooth_dispatcher_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
index fc76c3220ad0f89226b4a4357c0aee012d654821..3cb350333c096ac48063252393b9d9bf83876ea4 100644
--- a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
+++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
@@ -11,6 +11,7 @@ import android.os.Build;
import android.os.ParcelUuid;
import org.chromium.base.Log;
+import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -133,15 +134,20 @@ final class ChromeBluetoothDevice {
// Implements callbacks related to a GATT connection.
private class BluetoothGattCallbackImpl extends Wrappers.BluetoothGattCallbackWrapper {
@Override
- public void onConnectionStateChange(int status, int newState) {
+ public void onConnectionStateChange(final int status, final int newState) {
Log.i(TAG, "onConnectionStateChange status:%d newState:%s", status,
(newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED)
? "Connected"
: "Disconnected");
- if (mNativeBluetoothDeviceAndroid != 0) {
- nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
- newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);
- }
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (mNativeBluetoothDeviceAndroid != 0) {
+ nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
+ newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);
+ }
+ }
+ });
}
}
« no previous file with comments | « content/browser/bluetooth/bluetooth_dispatcher_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698