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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java

Issue 1998353002: Continuous Connect and Cancel Experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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: remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java b/remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c71de2fc77833d12d9a5d7ee3ac9e1b91af12c23
--- /dev/null
+++ b/remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chromoting;
+
+import android.os.Handler;
+import android.os.Looper;
+
+import org.chromium.base.Log;
+import org.chromium.chromoting.jni.Client;
+
+public class ConnectAndCancelTest {
+ private static final String TAG = "Chromoting";
+ private static final long RETRY_DELAY_MSEC = 1000;
+ private static ConnectAndCancelTest sTest;
+ private boolean mConnectScheduled;
+ private int mConnectCount;
+
+ private Chromoting mChromoting;
+
+ private ConnectAndCancelTest() {
+ mConnectScheduled = false;
+ mConnectCount = 0;
+ }
+
+ public static ConnectAndCancelTest getTest() {
+ if (sTest == null) {
+ sTest = new ConnectAndCancelTest();
+ }
+ return sTest;
+ }
+
+ public void start(Chromoting chromoting) {
+ mChromoting = chromoting;
+ delayedConnect();
+ }
+
+ public void onAuthDialog(Client client) {
+ client.destroy();
+ delayedConnect();
+ }
+
+ private void delayedConnect() {
+ if (mConnectScheduled) {
+ return;
+ }
+ mConnectScheduled = true;
+ new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ Log.d(TAG, "ConnectAndCancelTest connection count: %d", mConnectCount);
+ mConnectCount++;
+ mConnectScheduled = false;
+ mChromoting.onHostClicked(0);
+ }
+ }, RETRY_DELAY_MSEC);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698