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

Side by Side Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/util/LooperExecutor.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 unified diff | Download patch
OLDNEW
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
11 package org.appspot.apprtc.util; 11 package org.appspot.apprtc.util;
12 12
13 import android.os.Handler; 13 import android.os.Handler;
14 import android.os.Looper; 14 import android.os.Looper;
15 import android.util.Log; 15 import android.util.Log;
16 16
17 import java.util.LinkedList; 17 import java.util.LinkedList;
18 import java.util.List; 18 import java.util.List;
19 import java.util.concurrent.Executor; 19 import java.util.concurrent.Executor;
20 20
21 /** 21 /**
22 * Looper based executor class. 22 * Looper based executor class. This is needed because WebSocketClient from auto banh requires the
23 * thread to have a looper. The class is used in WebSocketRTCClient/WebSocketCha nnelClient.
23 */ 24 */
24 public class LooperExecutor extends Thread implements Executor { 25 public class LooperExecutor extends Thread implements Executor {
25 private static final String TAG = "LooperExecutor"; 26 private static final String TAG = "LooperExecutor";
26 // Object used to signal that looper thread has started and Handler instance 27 // Object used to signal that looper thread has started and Handler instance
27 // associated with looper thread has been allocated. 28 // associated with looper thread has been allocated.
28 private final Object looperStartedEvent = new Object(); 29 private final Object looperStartedEvent = new Object();
29 private final List<Runnable> scheduledPeriodicRunnables = new LinkedList<Runna ble>(); 30 private final List<Runnable> scheduledPeriodicRunnables = new LinkedList<Runna ble>();
30 private Handler handler = null; 31 private Handler handler = null;
31 private boolean running = false; 32 private boolean running = false;
32 private long threadId; 33 private long threadId;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return; 125 return;
125 } 126 }
126 if (Thread.currentThread().getId() == threadId) { 127 if (Thread.currentThread().getId() == threadId) {
127 runnable.run(); 128 runnable.run();
128 } else { 129 } else {
129 handler.post(runnable); 130 handler.post(runnable);
130 } 131 }
131 } 132 }
132 133
133 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698