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

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java

Issue 11647013: Enable Tracing on content shell for Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Extend new class from stdio subscriber. Created 7 years, 11 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content_shell; 5 package org.chromium.content_shell;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.BroadcastReceiver;
9 import android.content.Context;
8 import android.content.Intent; 10 import android.content.Intent;
11 import android.content.IntentFilter;
9 import android.os.Bundle; 12 import android.os.Bundle;
10 import android.text.TextUtils; 13 import android.text.TextUtils;
11 import android.util.Log; 14 import android.util.Log;
12 import android.view.KeyEvent; 15 import android.view.KeyEvent;
13 16
14 import org.chromium.base.ChromiumActivity; 17 import org.chromium.base.ChromiumActivity;
15 import org.chromium.content.app.LibraryLoader; 18 import org.chromium.content.app.LibraryLoader;
16 import org.chromium.content.browser.ActivityContentVideoViewDelegate; 19 import org.chromium.content.browser.ActivityContentVideoViewDelegate;
17 import org.chromium.content.browser.ContentVideoView; 20 import org.chromium.content.browser.ContentVideoView;
18 import org.chromium.content.browser.ContentView; 21 import org.chromium.content.browser.ContentView;
19 import org.chromium.content.browser.DeviceUtils; 22 import org.chromium.content.browser.DeviceUtils;
23 import org.chromium.content.browser.TraceController;
20 import org.chromium.content.common.CommandLine; 24 import org.chromium.content.common.CommandLine;
21 import org.chromium.ui.gfx.ActivityNativeWindow; 25 import org.chromium.ui.gfx.ActivityNativeWindow;
22 26
23 /** 27 /**
24 * Activity for managing the Content Shell. 28 * Activity for managing the Content Shell.
25 */ 29 */
26 public class ContentShellActivity extends ChromiumActivity { 30 public class ContentShellActivity extends ChromiumActivity {
27 31
28 public static final String COMMAND_LINE_FILE = "/data/local/tmp/content-shel l-command-line"; 32 public static final String COMMAND_LINE_FILE = "/data/local/tmp/content-shel l-command-line";
29 private static final String TAG = ContentShellActivity.class.getName(); 33 private static final String TAG = ContentShellActivity.class.getName();
30 34
31 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; 35 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl";
36 private static final String ACTION_START_TRACE = "org.chromium.content_shell .action.PROFILE_START";
Ted C 2013/01/04 17:40:48 >100 chars for this and the following line
37 private static final String ACTION_STOP_TRACE = "org.chromium.content_shell. action.PROFILE_STOP";
32 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; 38 public static final String DEFAULT_SHELL_URL = "http://www.google.com";
33 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; 39 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs";
34 40
35 private ShellManager mShellManager; 41 private ShellManager mShellManager;
36 private ActivityNativeWindow mActivityNativeWindow; 42 private ActivityNativeWindow mActivityNativeWindow;
43 private BroadcastReceiver mReceiver;
37 44
38 @Override 45 @Override
39 protected void onCreate(Bundle savedInstanceState) { 46 protected void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState); 47 super.onCreate(savedInstanceState);
41 48
42 // Initializing the command line must occur before loading the library. 49 // Initializing the command line must occur before loading the library.
43 if (!CommandLine.isInitialized()) { 50 if (!CommandLine.isInitialized()) {
44 CommandLine.initFromFile(COMMAND_LINE_FILE); 51 CommandLine.initFromFile(COMMAND_LINE_FILE);
45 String[] commandLineParams = getCommandLineParamsFromIntent(getInten t()); 52 String[] commandLineParams = getCommandLineParamsFromIntent(getInten t());
46 if (commandLineParams != null) { 53 if (commandLineParams != null) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 129 }
123 } 130 }
124 } 131 }
125 132
126 @Override 133 @Override
127 protected void onPause() { 134 protected void onPause() {
128 ContentView view = getActiveContentView(); 135 ContentView view = getActiveContentView();
129 if (view != null) view.onActivityPause(); 136 if (view != null) view.onActivityPause();
130 137
131 super.onPause(); 138 super.onPause();
139 unregisterReceiver(mReceiver);
132 } 140 }
133 141
134 @Override 142 @Override
135 protected void onResume() { 143 protected void onResume() {
136 super.onResume(); 144 super.onResume();
137 145
138 ContentView view = getActiveContentView(); 146 ContentView view = getActiveContentView();
139 if (view != null) view.onActivityResume(); 147 if (view != null) view.onActivityResume();
148 IntentFilter intentFilter = new IntentFilter(ACTION_START_TRACE);
149 intentFilter.addAction(ACTION_STOP_TRACE);
150 mReceiver = new BroadcastReceiver() {
151 @Override
152 public void onReceive(Context context, Intent intent) {
153 String action = intent.getAction();
154 String extra = intent.getStringExtra("file");
155 if (ACTION_START_TRACE.equals(action)) {
156 if (extra.isEmpty())
Ted C 2013/01/04 17:40:48 sadly the conventions across languages are differe
157 Log.e("ContentShell", "Can not start tracing without spe cifing saving location");
Ted C 2013/01/04 17:40:48 Although, you should use TAG from above instead of
158 else {
159 TraceController.beginTracing(extra);
160 Log.i("ContentShell", "start tracing");
Ted C 2013/01/04 17:40:48 Use TAG here too and in the else if below.
161 }
162 } else if (ACTION_STOP_TRACE.equals(action)) {
163 Log.i("ContentShell", "stop tracing");
164 TraceController.endTracing();
165 }
166 }
167 };
168 registerReceiver(mReceiver, intentFilter);
140 } 169 }
141 170
142 @Override 171 @Override
143 public void onActivityResult(int requestCode, int resultCode, Intent data) { 172 public void onActivityResult(int requestCode, int resultCode, Intent data) {
144 super.onActivityResult(requestCode, resultCode, data); 173 super.onActivityResult(requestCode, resultCode, data);
145 mActivityNativeWindow.onActivityResult(requestCode, resultCode, data); 174 mActivityNativeWindow.onActivityResult(requestCode, resultCode, data);
146 } 175 }
147 176
148 private static String getUrlFromIntent(Intent intent) { 177 private static String getUrlFromIntent(Intent intent) {
149 return intent != null ? intent.getDataString() : null; 178 return intent != null ? intent.getDataString() : null;
(...skipping 20 matching lines...) Expand all
170 199
171 /** 200 /**
172 * @return The {@link ContentView} owned by the currently visible {@link She ll} or null if one 201 * @return The {@link ContentView} owned by the currently visible {@link She ll} or null if one
173 * is not showing. 202 * is not showing.
174 */ 203 */
175 public ContentView getActiveContentView() { 204 public ContentView getActiveContentView() {
176 Shell shell = getActiveShell(); 205 Shell shell = getActiveShell();
177 return shell != null ? shell.getContentView() : null; 206 return shell != null ? shell.getContentView() : null;
178 } 207 }
179 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698