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

Unified Diff: blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Kevin's comments 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: blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java b/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
index cd830b17b1aba6d5e200fea9d0bc964f633cfaa1..3a52cad7f254d3cf7f1ec5081fd469ac45bb8d1d 100644
--- a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
+++ b/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
@@ -7,7 +7,10 @@ package org.chromium.blimp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
import android.text.TextUtils;
+import android.view.View;
+import android.widget.TextView;
import org.chromium.base.Log;
import org.chromium.base.annotations.SuppressFBWarnings;
@@ -21,18 +24,22 @@ import org.chromium.blimp.session.BlimpClientSession;
import org.chromium.blimp.session.EngineInfo;
import org.chromium.blimp.session.TabControlFeature;
import org.chromium.blimp.toolbar.Toolbar;
+import org.chromium.blimp.toolbar.ToolbarMenu;
import org.chromium.ui.widget.Toast;
/**
* The {@link Activity} for rendering the main Blimp client. This loads the Blimp rendering stack
* and displays it.
*/
-public class BlimpRendererActivity
- extends Activity implements BlimpLibraryLoader.Callback, TokenSource.Callback,
- BlimpClientSession.ConnectionObserver {
+public class BlimpRendererActivity extends Activity
+ implements BlimpLibraryLoader.Callback, TokenSource.Callback,
+ BlimpClientSession.ConnectionObserver, ToolbarMenu.ToolbarMenuDelegate {
private static final int ACCOUNT_CHOOSER_INTENT_REQUEST_CODE = 100;
private static final String TAG = "BlimpRendererActivity";
+ // Refresh interval for the debug view.
Kevin M 2016/05/20 01:02:01 What's the time unit for this interval?
shaktisahu 2016/05/22 22:36:55 milliseconds.
+ private static final int DEBUG_VIEW_REFRESH_INTERVAL = 1000;
+
/** Provides user authentication tokens that can be used to query for engine assignments. This
* can potentially query GoogleAuthUtil for an OAuth2 authentication token with userinfo.email
* privileges for a chosen Android account. */
@@ -44,6 +51,8 @@ public class BlimpRendererActivity
private TabControlFeature mTabControlFeature;
private WebInputBox mWebInputBox;
+ private Handler mHandler = new Handler();
+
private boolean mFirstUrlLoadDone = false;
@Override
@@ -83,9 +92,6 @@ public class BlimpRendererActivity
}
if (mToolbar != null) {
- if (mBlimpClientSession != null) {
- mBlimpClientSession.removeObserver(mToolbar);
- }
mToolbar.destroy();
mToolbar = null;
}
@@ -154,7 +160,6 @@ public class BlimpRendererActivity
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.initialize(mBlimpClientSession);
- mBlimpClientSession.addObserver(mToolbar);
mWebInputBox = (WebInputBox) findViewById(R.id.editText);
mWebInputBox.initialize(mBlimpClientSession);
@@ -164,6 +169,27 @@ public class BlimpRendererActivity
handleUrlFromIntent(getIntent());
}
+ // ToolbarMenu.ToolbarMenuDelegate implementation.
+ @Override
+ public void showDebugView(boolean show) {
+ View debugView = findViewById(R.id.debug_stats);
+ debugView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+ if (show) {
+ Runnable debugStatsRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (mToolbar.getToolbarMenu().isDebugInfoEnabled()) {
+ mBlimpClientSession.getDebugStats();
+ mHandler.postDelayed(this, DEBUG_VIEW_REFRESH_INTERVAL);
+ }
+ }
+ };
+ debugStatsRunnable.run();
+ } else {
+ mBlimpClientSession.disableDebugStats();
+ }
+ }
+
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
@@ -234,6 +260,16 @@ public class BlimpRendererActivity
}
@Override
+ public void updateDebugInfo(int received, int sent, int commits) {
+ TextView tv = (TextView) findViewById(R.id.bytes_received_client);
+ tv.setText(String.valueOf(received / 1000));
+ tv = (TextView) findViewById(R.id.bytes_sent_client);
+ tv.setText(String.valueOf(sent / 1000));
+ tv = (TextView) findViewById(R.id.commit_count);
+ tv.setText(String.valueOf(commits));
+ }
+
+ @Override
public void onDisconnected(String reason) {
Toast.makeText(this,
String.format(getResources().getString(R.string.network_disconnected), reason),

Powered by Google App Engine
This is Rietveld 408576698