Chromium Code Reviews| Index: content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java |
| diff --git a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java |
| index bddb70f316753ae564bb10700aea9dad876fadb3..d21089b5257faec5440ff5d76d58c4c46205ab90 100644 |
| --- a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java |
| +++ b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java |
| @@ -5,7 +5,10 @@ |
| package org.chromium.content_shell; |
| import android.app.Activity; |
| +import android.content.BroadcastReceiver; |
| +import android.content.Context; |
| import android.content.Intent; |
| +import android.content.IntentFilter; |
| import android.os.Bundle; |
| import android.text.TextUtils; |
| import android.util.Log; |
| @@ -29,11 +32,14 @@ public class ContentShellActivity extends ChromiumActivity { |
| private static final String TAG = ContentShellActivity.class.getName(); |
| private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; |
| + private static final String ACTION_START_TRACE = "com.contentshell.action.PROFILE_START"; |
|
Ted C
2012/12/26 16:18:28
This should probably be:
org.chromium.content_she
|
| + private static final String ACTION_STOP_TRACE = "com.contentshell.action.PROFILE_STOP"; |
| public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; |
| private ShellManager mShellManager; |
| private ActivityNativeWindow mActivityNativeWindow; |
| + private BroadcastReceiver mReceiver; |
| @Override |
| protected void onCreate(Bundle savedInstanceState) { |
| @@ -129,6 +135,7 @@ public class ContentShellActivity extends ChromiumActivity { |
| if (view != null) view.onActivityPause(); |
| super.onPause(); |
| + unregisterReceiver(mReceiver); |
| } |
| @Override |
| @@ -137,8 +144,26 @@ public class ContentShellActivity extends ChromiumActivity { |
| ContentView view = getActiveContentView(); |
| if (view != null) view.onActivityResume(); |
| + IntentFilter intentFilter = new IntentFilter(ACTION_START_TRACE); |
| + intentFilter.addAction(ACTION_STOP_TRACE); |
| + mReceiver = new BroadcastReceiver() { |
| + @Override |
| + public void onReceive(Context context, Intent intent) { |
| + String action = intent.getAction(); |
| + String extra = intent.getStringExtra("file"); |
| + if (action.equals(ACTION_START_TRACE) && (extra.length() > 0)) { |
|
Ted C
2012/12/26 16:18:28
When comparing against constants, I prefer to use
|
| + Log.i("ContentShell", "start tracing"); |
| + TraceController.beginTracing(extra); |
| + } else if (action.equals(ACTION_STOP_TRACE)) { |
| + Log.i("ContentShell", "stop tracing"); |
| + TraceController.endTracing(); |
| + } |
| + } |
| + }; |
| + registerReceiver(mReceiver, intentFilter); |
| } |
| + |
|
Ted C
2012/12/26 16:18:28
no need for this extra line
|
| @Override |
| public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| super.onActivityResult(requestCode, resultCode, data); |