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

Unified Diff: content/browser/android/tracing_intent_handler.cc

Issue 11647013: Enable Tracing on content shell for Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add OVERRIDE to fix clang build error 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/android/tracing_intent_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/tracing_intent_handler.cc
diff --git a/content/browser/android/tracing_intent_handler.cc b/content/browser/android/tracing_intent_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2b44a461f02ca4460e9bd7357e81e1a1d6cbb664
--- /dev/null
+++ b/content/browser/android/tracing_intent_handler.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 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.
+
+#include "content/browser/android/tracing_intent_handler.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "base/logging.h"
+#include "content/public/browser/trace_controller.h"
+#include "jni/TracingIntentHandler_jni.h"
+
+namespace content {
+
+TracingIntentHandler* g_trace_intent_handler = NULL;
+
+TracingIntentHandler::TracingIntentHandler(const FilePath& path)
+ : TraceSubscriberStdio(path) {
+ TraceController::GetInstance()->BeginTracing(this, std::string("-test*"));
+}
+
+TracingIntentHandler::~TracingIntentHandler() {
+}
+
+void TracingIntentHandler::OnEndTracingComplete() {
+ TraceSubscriberStdio::OnEndTracingComplete();
+ delete this;
+}
+
+void TracingIntentHandler::OnEndTracing() {
+ if (!TraceController::GetInstance()->EndTracingAsync(this)) {
+ delete this;
+ }
+}
+
+static void BeginTracing(JNIEnv* env, jclass clazz, jstring jspath) {
+ std::string path(base::android::ConvertJavaStringToUTF8(env, jspath));
+ if (g_trace_intent_handler != NULL)
+ return;
+ g_trace_intent_handler = new TracingIntentHandler(FilePath(path));
+}
+
+static void EndTracing(JNIEnv* env, jclass clazz) {
+ DCHECK(!g_trace_intent_handler);
+ g_trace_intent_handler->OnEndTracing();
+ g_trace_intent_handler = NULL;
+}
+
+bool RegisterTracingIntentHandler(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace content
« no previous file with comments | « content/browser/android/tracing_intent_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698