| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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 "base/android/early_trace_event_binding.h" |
| 6 |
| 7 #include "base/android/jni_string.h" |
| 8 #include "base/time/time.h" |
| 9 #include "base/trace_event/trace_event.h" |
| 10 #include "jni/EarlyTraceEvent_jni.h" |
| 11 |
| 12 namespace base { |
| 13 namespace android { |
| 14 |
| 15 const char kEarlyJavaCategory[] = "EarlyJava"; |
| 16 |
| 17 static jlong GetTimeTicksNowUs(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 18 return TimeTicks::Now().ToInternalValue(); |
| 19 } |
| 20 |
| 21 static void RecordEarlyEvent(JNIEnv* env, |
| 22 const JavaParamRef<jclass>& clazz, |
| 23 const JavaParamRef<jstring>& jname, |
| 24 jlong begin_time_ms, |
| 25 jlong end_time_ms, |
| 26 jint thread_id) { |
| 27 std::string name = ConvertJavaStringToUTF8(env, jname); |
| 28 int64 begin_us = begin_time_ms * 1000; |
| 29 int64 end_us = end_time_ms * 1000; |
| 30 |
| 31 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( |
| 32 TRACE_EVENT_PHASE_BEGIN, kEarlyJavaCategory, name.c_str(), |
| 33 trace_event_internal::kNoId, thread_id, begin_us, TRACE_EVENT_FLAG_COPY); |
| 34 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( |
| 35 TRACE_EVENT_PHASE_END, kEarlyJavaCategory, name.c_str(), |
| 36 trace_event_internal::kNoId, thread_id, end_us, TRACE_EVENT_FLAG_COPY); |
| 37 } |
| 38 |
| 39 bool RegisterEarlyTraceEvent(JNIEnv* env) { |
| 40 return RegisterNativesImpl(env); |
| 41 } |
| 42 |
| 43 } // namespace android |
| 44 } // namespace base |
| OLD | NEW |