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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 void TracingControllerAndroid::Destroy(JNIEnv* env, jobject obj) { | 28 void TracingControllerAndroid::Destroy(JNIEnv* env, jobject obj) { |
29 delete this; | 29 delete this; |
30 } | 30 } |
31 | 31 |
32 bool TracingControllerAndroid::StartTracing(JNIEnv* env, | 32 bool TracingControllerAndroid::StartTracing(JNIEnv* env, |
33 jobject obj, | 33 jobject obj, |
34 jstring jcategories, | 34 jstring jcategories, |
35 jstring jtraceoptions) { | 35 jstring jtraceoptions) { |
36 std::string categories = | 36 std::string categories = |
37 base::android::ConvertJavaStringToUTF8(env, jcategories); | 37 base::android::ConvertJavaStringToUTF8(env, jcategories); |
38 base::trace_event::TraceOptions trace_options; | 38 std::string options = |
39 trace_options.SetFromString( | 39 base::android::ConvertJavaStringToUTF8(env, jtraceoptions); |
40 base::android::ConvertJavaStringToUTF8(env, jtraceoptions)); | |
41 | 40 |
42 // This log is required by adb_profile_chrome.py. | 41 // This log is required by adb_profile_chrome.py. |
43 LOG(WARNING) << "Logging performance trace to file"; | 42 LOG(WARNING) << "Logging performance trace to file"; |
44 | 43 |
45 return TracingController::GetInstance()->EnableRecording( | 44 return TracingController::GetInstance()->EnableRecording( |
46 base::trace_event::CategoryFilter(categories), | 45 base::trace_event::TraceConfig(categories, options), |
47 trace_options, | |
48 TracingController::EnableRecordingDoneCallback()); | 46 TracingController::EnableRecordingDoneCallback()); |
49 } | 47 } |
50 | 48 |
51 void TracingControllerAndroid::StopTracing(JNIEnv* env, | 49 void TracingControllerAndroid::StopTracing(JNIEnv* env, |
52 jobject obj, | 50 jobject obj, |
53 jstring jfilepath) { | 51 jstring jfilepath) { |
54 base::FilePath file_path( | 52 base::FilePath file_path( |
55 base::android::ConvertJavaStringToUTF8(env, jfilepath)); | 53 base::android::ConvertJavaStringToUTF8(env, jfilepath)); |
56 if (!TracingController::GetInstance()->DisableRecording( | 54 if (!TracingController::GetInstance()->DisableRecording( |
57 TracingController::CreateFileSink( | 55 TracingController::CreateFileSink( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 category_list.AppendString(*it); | 96 category_list.AppendString(*it); |
99 } | 97 } |
100 std::string received_category_list; | 98 std::string received_category_list; |
101 base::JSONWriter::Write(category_list, &received_category_list); | 99 base::JSONWriter::Write(category_list, &received_category_list); |
102 | 100 |
103 // This log is required by adb_profile_chrome.py. | 101 // This log is required by adb_profile_chrome.py. |
104 LOG(WARNING) << "{\"traceCategoriesList\": " << received_category_list << "}"; | 102 LOG(WARNING) << "{\"traceCategoriesList\": " << received_category_list << "}"; |
105 } | 103 } |
106 | 104 |
107 static jstring GetDefaultCategories(JNIEnv* env, jobject obj) { | 105 static jstring GetDefaultCategories(JNIEnv* env, jobject obj) { |
| 106 base::trace_event::TraceConfig trace_config; |
108 return base::android::ConvertUTF8ToJavaString( | 107 return base::android::ConvertUTF8ToJavaString( |
109 env, | 108 env, |
110 base::trace_event::CategoryFilter::kDefaultCategoryFilterString) | 109 trace_config.ToCategoryFilterString()) |
111 .Release(); | 110 .Release(); |
112 } | 111 } |
113 | 112 |
114 bool RegisterTracingControllerAndroid(JNIEnv* env) { | 113 bool RegisterTracingControllerAndroid(JNIEnv* env) { |
115 return RegisterNativesImpl(env); | 114 return RegisterNativesImpl(env); |
116 } | 115 } |
117 | 116 |
118 } // namespace content | 117 } // namespace content |
OLD | NEW |