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

Side by Side 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, 6 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chromoting;
6
7 import android.os.Handler;
8 import android.os.Looper;
9
10 import org.chromium.base.Log;
11 import org.chromium.chromoting.jni.Client;
12
13 public class ConnectAndCancelTest {
14 private static final String TAG = "Chromoting";
15 private static final long RETRY_DELAY_MSEC = 1000;
16 private static ConnectAndCancelTest sTest;
17 private boolean mConnectScheduled;
18 private int mConnectCount;
19
20 private Chromoting mChromoting;
21
22 private ConnectAndCancelTest() {
23 mConnectScheduled = false;
24 mConnectCount = 0;
25 }
26
27 public static ConnectAndCancelTest getTest() {
28 if (sTest == null) {
29 sTest = new ConnectAndCancelTest();
30 }
31 return sTest;
32 }
33
34 public void start(Chromoting chromoting) {
35 mChromoting = chromoting;
36 delayedConnect();
37 }
38
39 public void onAuthDialog(Client client) {
40 client.destroy();
41 delayedConnect();
42 }
43
44 private void delayedConnect() {
45 if (mConnectScheduled) {
46 return;
47 }
48 mConnectScheduled = true;
49 new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
50 @Override
51 public void run() {
52 Log.d(TAG, "ConnectAndCancelTest connection count: %d", mConnect Count);
53 mConnectCount++;
54 mConnectScheduled = false;
55 mChromoting.onHostClicked(0);
56 }
57 }, RETRY_DELAY_MSEC);
58 }
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698