| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_controller_android.h" | 5 #include "content/browser/android/tracing_controller_android.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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 trace_options, | 47 trace_options, |
| 48 TracingController::EnableRecordingDoneCallback()); | 48 TracingController::EnableRecordingDoneCallback()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void TracingControllerAndroid::StopTracing(JNIEnv* env, | 51 void TracingControllerAndroid::StopTracing(JNIEnv* env, |
| 52 jobject obj, | 52 jobject obj, |
| 53 jstring jfilepath) { | 53 jstring jfilepath) { |
| 54 base::FilePath file_path( | 54 base::FilePath file_path( |
| 55 base::android::ConvertJavaStringToUTF8(env, jfilepath)); | 55 base::android::ConvertJavaStringToUTF8(env, jfilepath)); |
| 56 if (!TracingController::GetInstance()->DisableRecording( | 56 if (!TracingController::GetInstance()->DisableRecording( |
| 57 file_path, | 57 TracingController::CreateFileSink( |
| 58 base::Bind(&TracingControllerAndroid::OnTracingStopped, | 58 file_path, |
| 59 weak_factory_.GetWeakPtr()))) { | 59 base::Bind(&TracingControllerAndroid::OnTracingStopped, |
| 60 weak_factory_.GetWeakPtr())))) { |
| 60 LOG(ERROR) << "EndTracingAsync failed, forcing an immediate stop"; | 61 LOG(ERROR) << "EndTracingAsync failed, forcing an immediate stop"; |
| 61 OnTracingStopped(file_path); | 62 OnTracingStopped(); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 void TracingControllerAndroid::GenerateTracingFilePath( | 66 void TracingControllerAndroid::GenerateTracingFilePath( |
| 66 base::FilePath* file_path) { | 67 base::FilePath* file_path) { |
| 67 JNIEnv* env = base::android::AttachCurrentThread(); | 68 JNIEnv* env = base::android::AttachCurrentThread(); |
| 68 ScopedJavaLocalRef<jstring> jfilename = | 69 ScopedJavaLocalRef<jstring> jfilename = |
| 69 Java_TracingControllerAndroid_generateTracingFilePath(env); | 70 Java_TracingControllerAndroid_generateTracingFilePath(env); |
| 70 *file_path = base::FilePath( | 71 *file_path = base::FilePath( |
| 71 base::android::ConvertJavaStringToUTF8(env, jfilename.obj())); | 72 base::android::ConvertJavaStringToUTF8(env, jfilename.obj())); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void TracingControllerAndroid::OnTracingStopped( | 75 void TracingControllerAndroid::OnTracingStopped() { |
| 75 const base::FilePath& file_path) { | |
| 76 JNIEnv* env = base::android::AttachCurrentThread(); | 76 JNIEnv* env = base::android::AttachCurrentThread(); |
| 77 base::android::ScopedJavaLocalRef<jobject> obj = weak_java_object_.get(env); | 77 base::android::ScopedJavaLocalRef<jobject> obj = weak_java_object_.get(env); |
| 78 if (obj.obj()) | 78 if (obj.obj()) |
| 79 Java_TracingControllerAndroid_onTracingStopped(env, obj.obj()); | 79 Java_TracingControllerAndroid_onTracingStopped(env, obj.obj()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool TracingControllerAndroid::GetKnownCategoryGroupsAsync(JNIEnv* env, | 82 bool TracingControllerAndroid::GetKnownCategoryGroupsAsync(JNIEnv* env, |
| 83 jobject obj) { | 83 jobject obj) { |
| 84 if (!TracingController::GetInstance()->GetCategories( | 84 if (!TracingController::GetInstance()->GetCategories( |
| 85 base::Bind(&TracingControllerAndroid::OnKnownCategoriesReceived, | 85 base::Bind(&TracingControllerAndroid::OnKnownCategoriesReceived, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 107 static jstring GetDefaultCategories(JNIEnv* env, jobject obj) { | 107 static jstring GetDefaultCategories(JNIEnv* env, jobject obj) { |
| 108 return base::android::ConvertUTF8ToJavaString(env, | 108 return base::android::ConvertUTF8ToJavaString(env, |
| 109 base::debug::CategoryFilter::kDefaultCategoryFilterString).Release(); | 109 base::debug::CategoryFilter::kDefaultCategoryFilterString).Release(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool RegisterTracingControllerAndroid(JNIEnv* env) { | 112 bool RegisterTracingControllerAndroid(JNIEnv* env) { |
| 113 return RegisterNativesImpl(env); | 113 return RegisterNativesImpl(env); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace content | 116 } // namespace content |
| OLD | NEW |