Index: content/common/android/trace_event_binding.cc |
diff --git a/content/common/android/trace_event_binding.cc b/content/common/android/trace_event_binding.cc |
index 3b14de076dbc985125f0e1781254e55ef80a3b5d..bba9eed57b1a9910be4cc5a5f4c777f940c8d669 100644 |
--- a/content/common/android/trace_event_binding.cc |
+++ b/content/common/android/trace_event_binding.cc |
@@ -23,12 +23,12 @@ class TraceEventDataConverter { |
jstring jname, |
jstring jarg) |
: env_(env), |
- jname_(jname), |
- jarg_(jarg), |
- name_(env->GetStringUTFChars(jname, NULL)), |
- arg_(jarg ? env->GetStringUTFChars(jarg, NULL) : NULL) { |
+ jname_(jname), |
+ jarg_(jarg), |
+ name_(env->GetStringUTFChars(jname, NULL)), |
+ arg_(jarg ? env->GetStringUTFChars(jarg, NULL) : NULL) { |
} |
- ~TraceEventDataConverter() { |
+ virtual ~TraceEventDataConverter() { |
env_->ReleaseStringUTFChars(jname_, name_); |
if (jarg_) |
env_->ReleaseStringUTFChars(jarg_, arg_); |
@@ -39,8 +39,10 @@ class TraceEventDataConverter { |
const char* arg_name() { return arg_ ? "arg" : NULL; } |
const char* arg() { return arg_; } |
- private: |
+ protected: |
JNIEnv* env_; |
+ |
+ private: |
jstring jname_; |
jstring jarg_; |
const char* name_; |
@@ -49,6 +51,25 @@ class TraceEventDataConverter { |
DISALLOW_COPY_AND_ASSIGN(TraceEventDataConverter); |
}; |
+class AsyncTraceEventDataConverter : public TraceEventDataConverter { |
+ public: |
+ AsyncTraceEventDataConverter(JNIEnv* env, |
+ jstring jname, |
+ jlong jid, |
+ jstring jarg) |
+ : TraceEventDataConverter(env, jname, jarg), |
+ id_(jid) { |
+ } |
+ |
+ virtual ~AsyncTraceEventDataConverter() { |
+ } |
+ |
+ const long long id() { return id_; } |
+ |
+ private: |
+ long long id_; |
+}; |
+ |
} // namespace |
static jboolean TraceEnabled(JNIEnv* env, jclass clazz) { |
@@ -88,6 +109,38 @@ static void End(JNIEnv* env, jclass clazz, |
} |
} |
+static void StartAsync(JNIEnv* env, jclass clazz, |
+ jstring jname, jlong jid, jstring jarg) { |
+ AsyncTraceEventDataConverter converter(env, jname, jid, jarg); |
+ if (converter.arg()) { |
+ TRACE_EVENT_COPY_ASYNC_BEGIN1(kJavaCategory, |
+ converter.name(), |
+ converter.id(), |
+ converter.arg_name(), |
+ converter.arg()); |
+ } else { |
+ TRACE_EVENT_COPY_ASYNC_BEGIN0(kJavaCategory, |
+ converter.name(), |
+ converter.id()); |
+ } |
+} |
+ |
+static void FinishAsync(JNIEnv* env, jclass clazz, |
+ jstring jname, jlong jid, jstring jarg) { |
+ AsyncTraceEventDataConverter converter(env, jname, jid, jarg); |
+ if (converter.arg()) { |
+ TRACE_EVENT_COPY_ASYNC_END1(kJavaCategory, |
+ converter.name(), |
+ converter.id(), |
+ converter.arg_name(), |
+ converter.arg()); |
+ } else { |
+ TRACE_EVENT_COPY_ASYNC_END0(kJavaCategory, |
+ converter.name(), |
+ converter.id()); |
+ } |
+} |
+ |
bool RegisterTraceEvent(JNIEnv* env) { |
return RegisterNativesImpl(env); |
} |