提交 557fa4f6 编写于 作者: A Adam Barth

Merge pull request #2293 from abarth/raw_keyboard_leak

RawKeyboardService leaks
......@@ -15,5 +15,4 @@ interface RawKeyboardListener {
[ServiceName="raw_keyboard::RawKeyboardService"]
interface RawKeyboardService {
AddListener(RawKeyboardListener listener);
RemoveListener(RawKeyboardListener listener);
};
......@@ -20,12 +20,7 @@ public class RawKeyboardServiceImpl implements RawKeyboardService {
@Override
public void addListener(RawKeyboardListener listener) {
mViewState.addListener(listener);
}
@Override
public void removeListener(RawKeyboardListener listener) {
mViewState.removeListener(listener);
mViewState.addListener((RawKeyboardListener.Proxy) listener);
}
@Override
......
......@@ -10,6 +10,7 @@ import android.view.View;
import java.util.ArrayList;
import org.chromium.mojo.bindings.ConnectionErrorHandler;
import org.chromium.mojo.system.MojoException;
import org.chromium.mojom.raw_keyboard.RawKeyboardListener;
import org.chromium.mojom.raw_keyboard.RawKeyboardService;
......@@ -23,18 +24,19 @@ import org.chromium.mojom.sky.KeyData;
public class RawKeyboardServiceState implements View.OnKeyListener {
private static final String TAG = "RawKeyboardServiceState";
private ArrayList<RawKeyboardListener> mListeners = new ArrayList<RawKeyboardListener>();
private ArrayList<RawKeyboardListener.Proxy> mListeners = new ArrayList<RawKeyboardListener.Proxy>();
public RawKeyboardServiceState() {
}
public void addListener(RawKeyboardListener listener) {
public void addListener(final RawKeyboardListener.Proxy listener) {
mListeners.add(listener);
}
public void removeListener(RawKeyboardListener listener) {
mListeners.remove(listener);
listener.close();
listener.getProxyHandler().setErrorHandler(new ConnectionErrorHandler() {
@Override
public void onConnectionError(MojoException e) {
mListeners.remove(listener);
}
});
}
public void close() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册