Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1507)

Unified Diff: base/android/early_trace_event_binding.cc

Issue 1486053003: Android: Add support for TraceEvent before the native library is loaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fix test. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/early_trace_event_binding.cc
diff --git a/base/android/early_trace_event_binding.cc b/base/android/early_trace_event_binding.cc
new file mode 100644
index 0000000000000000000000000000000000000000..19e5d8d62987fe6da9ddd2e1470a1e55ae144014
--- /dev/null
+++ b/base/android/early_trace_event_binding.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/android/early_trace_event_binding.h"
+
+#include <stdint.h>
+
+#include "base/android/jni_string.h"
+#include "base/time/time.h"
+#include "base/trace_event/trace_event.h"
+#include "jni/EarlyTraceEvent_jni.h"
+
+namespace base {
+namespace android {
+
+const char kEarlyJavaCategory[] = "EarlyJava";
+
+static jlong GetTimeTicksNowUs(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
+ return TimeTicks::Now().ToInternalValue();
+}
+
+static void RecordEarlyEvent(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jstring>& jname,
+ jlong begin_time_ms,
+ jlong end_time_ms,
+ jint thread_id) {
+ std::string name = ConvertJavaStringToUTF8(env, jname);
+ int64_t begin_us = begin_time_ms * 1000;
+ int64_t end_us = end_time_ms * 1000;
+
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(
+ TRACE_EVENT_PHASE_BEGIN, kEarlyJavaCategory, name.c_str(),
+ trace_event_internal::kNoId, thread_id, begin_us, TRACE_EVENT_FLAG_COPY);
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(
+ TRACE_EVENT_PHASE_END, kEarlyJavaCategory, name.c_str(),
+ trace_event_internal::kNoId, thread_id, end_us, TRACE_EVENT_FLAG_COPY);
+}
+
+bool RegisterEarlyTraceEvent(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace android
+} // namespace base
« no previous file with comments | « base/android/early_trace_event_binding.h ('k') | base/android/java/src/org/chromium/base/EarlyTraceEvent.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698