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

Side by Side 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: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/android/tracing_intent_handler.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "base/logging.h"
10 #include "content/public/browser/trace_controller.h"
11 #include "jni/TraceController_jni.h"
12
13 namespace content {
14
15 TracingIntentHandler* g_trace_intent_handler = NULL;
16
17 TracingIntentHandler::TracingIntentHandler(const FilePath& path)
18 : TraceSubscriberStdio(path) {
19 TraceController::GetInstance()->BeginTracing(this, std::string("-test*"));
20 }
21
22 void TracingIntentHandler::OnEndTracingComplete() {
23 TraceSubscriberStdio::OnEndTracingComplete();
24 delete this;
25 }
26
27 void TracingIntentHandler::OnEndTracing() {
28 if (!TraceController::GetInstance()->EndTracingAsync(this)) {
29 delete this;
30 }
31 }
32
33 static void BeginTracing(JNIEnv* env, jclass clazz, jstring jspath) {
34 std::string path(base::android::ConvertJavaStringToUTF8(env, jspath));
35 if (g_trace_intent_handler != NULL)
36 return;
37 g_trace_intent_handler = new TracingIntentHandler(FilePath(path));
38 }
39
40 static void EndTracing(JNIEnv* env, jclass clazz) {
41 DCHECK(!g_trace_intent_handler);
42 g_trace_intent_handler->OnEndTracing();
43 g_trace_intent_handler = NULL;
44 }
45
46 bool RegisterTracingIntentHandler(JNIEnv* env) {
47 return RegisterNativesImpl(env);
48 }
49
50 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698