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