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

Unified Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java

Issue 1992213002: Replace LooperExecutor with built-in class in Android AppRTC Demo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
Index: webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java
index 3de0dc03b399c9e62edf8bbf16515f3f07705aaa..4b6c87719efe62352a93145729c77813434b8ff9 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java
@@ -12,7 +12,6 @@ package org.appspot.apprtc;
import android.util.Log;
-import org.appspot.apprtc.util.LooperExecutor;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -21,6 +20,8 @@ import org.webrtc.PeerConnection;
import org.webrtc.SessionDescription;
import java.util.LinkedList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -52,7 +53,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
+ "(:(\\d+))?"
);
- private final LooperExecutor executor;
+ private final ExecutorService executor;
private final SignalingEvents events;
private TCPChannelClient tcpClient;
private RoomConnectionParameters connectionParameters;
@@ -64,11 +65,10 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
// All alterations of the room state should be done from inside the looper thread.
private ConnectionState roomState;
- public DirectRTCClient(SignalingEvents events, LooperExecutor looperExecutor) {
+ public DirectRTCClient(SignalingEvents events) {
this.events = events;
- executor = looperExecutor;
- executor.requestStart();
+ executor = Executors.newSingleThreadExecutor();
roomState = ConnectionState.NEW;
}
@@ -148,6 +148,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
tcpClient.disconnect();
tcpClient = null;
}
+ executor.shutdown();
magjed_webrtc 2016/05/19 12:07:54 What happens if connectToRoom() is called again? B
sakal 2016/05/19 12:39:03 Executor gets shutdown too early if it is shutdown
}
@Override
@@ -295,13 +296,11 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
@Override
public void onTCPError(String description) {
reportError("TCP connection error: " + description);
- executor.requestStop();
}
@Override
public void onTCPClose() {
events.onChannelClose();
- executor.requestStop();
}
// --------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698